26 #ifndef SMESH_Block_HeaderFile 27 #define SMESH_Block_HeaderFile 36 #include <TopTools_IndexedMapOfOrientedShape.hxx> 37 #include <TopoDS_Edge.hxx> 38 #include <TopoDS_Face.hxx> 39 #include <TopoDS_Shell.hxx> 40 #include <TopoDS_Vertex.hxx> 43 #include <math_FunctionSetWithDerivatives.hxx> 70 ID_V000 = 1, ID_V100, ID_V010, ID_V110, ID_V001, ID_V101, ID_V011,
ID_V111,
76 ID_Fxy0,
ID_Fxy1, ID_Fx0z, ID_Fx1z, ID_F0yz, ID_F1yz,
82 ID_FirstV = ID_V000, ID_FirstE = ID_Ex00, ID_FirstF = ID_Fxy0
99 {
return ( theShapeID >= ID_V000 && theShapeID <= ID_V111 ); }
102 {
return ( theShapeID >= ID_Ex00 && theShapeID <= ID_E11z ); }
105 {
return ( theShapeID >= ID_Fxy0 && theShapeID <= ID_F1yz ); }
109 if ( IsVertexID( theShapeID ))
return theShapeID - ID_V000;
110 if ( IsEdgeID( theShapeID ))
return theShapeID - ID_Ex00;
111 if ( IsFaceID( theShapeID ))
return theShapeID - ID_Fxy0;
119 static void GetFaceEdgesIDs (
const int faceID, std::vector< int >& edgeVec );
122 static void GetEdgeVertexIDs (
const int edgeID, std::vector< int >& vertexVec );
126 {
return (theEdgeID < ID_E0y0) ? 1 : (theEdgeID < ID_E00z) ? 2 : 3; }
129 static double* GetShapeCoef (
const int theShapeID);
137 static int GetShapeIDByParams (
const gp_XYZ& theParams );
140 static std::ostream& DumpShapeID (
const int theBlockShapeID, std::ostream& stream);
151 bool LoadBlockShapes(
const TopoDS_Shell& theShell,
152 const TopoDS_Vertex& theVertex000,
153 const TopoDS_Vertex& theVertex001,
154 TopTools_IndexedMapOfOrientedShape& theShapeIDMap );
159 bool LoadBlockShapes(
const TopTools_IndexedMapOfOrientedShape& theShapeIDMap);
163 const int theNode000Index,
164 const int theNode001Index,
165 std::vector<const SMDS_MeshNode*>& theOrderedNodes);
169 bool LoadFace(
const TopoDS_Face& theFace,
171 const TopTools_IndexedMapOfOrientedShape& theShapeIDMap);
176 static bool Insert(
const TopoDS_Shape& theShape,
177 const int theShapeID,
178 TopTools_IndexedMapOfOrientedShape& theShapeIDMap);
183 static bool FindBlockShapes(
const TopoDS_Shell& theShell,
184 const TopoDS_Vertex& theVertex000,
185 const TopoDS_Vertex& theVertex001,
186 TopTools_IndexedMapOfOrientedShape& theShapeIDMap );
195 bool VertexPoint(
const int theVertexID, gp_XYZ& thePoint )
const {
196 if ( !IsVertexID( theVertexID ))
return false;
197 thePoint = myPnt[ theVertexID - ID_FirstV ];
return true;
201 bool EdgePoint(
const int theEdgeID,
const gp_XYZ& theParams, gp_XYZ& thePoint )
const {
202 if ( !IsEdgeID( theEdgeID ))
return false;
203 thePoint = myEdge[ theEdgeID - ID_FirstE ].Point( theParams );
return true;
207 bool EdgeU(
const int theEdgeID,
const gp_XYZ& theParams,
double& theU )
const {
208 if ( !IsEdgeID( theEdgeID ))
return false;
209 theU = myEdge[ theEdgeID - ID_FirstE ].GetU( theParams );
return true;
213 bool FacePoint(
const int theFaceID,
const gp_XYZ& theParams, gp_XYZ& thePoint )
const {
214 if ( !IsFaceID ( theFaceID ))
return false;
215 thePoint = myFace[ theFaceID - ID_FirstF ].Point( theParams );
return true;
219 bool FaceUV(
const int theFaceID,
const gp_XYZ& theParams, gp_XY& theUV )
const {
220 if ( !IsFaceID ( theFaceID ))
return false;
221 theUV = myFace[ theFaceID - ID_FirstF ].GetUV( theParams );
return true;
225 bool ShellPoint(
const gp_XYZ& theParams, gp_XYZ& thePoint )
const;
228 static bool ShellPoint(
const gp_XYZ& theParams,
229 const std::vector<gp_XYZ>& thePointOnShape,
242 bool ComputeParameters (
const gp_Pnt& thePoint,
244 const int theShapeID = ID_Shell,
245 const gp_XYZ& theParamsHint = gp_XYZ(-1,-1,-1));
249 bool VertexParameters(
const int theVertexID, gp_XYZ& theParams);
252 bool EdgeParameters(
const int theEdgeID,
const double theU, gp_XYZ& theParams);
269 const TopTools_IndexedMapOfOrientedShape& theShapeIDMap) {
270 int v1ID = theShapeIDMap.FindIndex( TopExp::FirstVertex( theEdge ).Oriented( TopAbs_FORWARD ));
271 int v2ID = theShapeIDMap.FindIndex( TopExp::LastVertex( theEdge ).Oriented( TopAbs_FORWARD ));
272 return ( v1ID < v2ID );
276 static int GetOrderedEdges (
const TopoDS_Face& theFace,
277 TopoDS_Vertex theFirstVertex,
278 std::list< TopoDS_Edge >& theEdges,
279 std::list< int > & theNbVertexInWires,
280 const bool theShapeAnalysisAlgo=
false);
293 Standard_Integer NbVariables()
const;
294 Standard_Integer NbEquations()
const;
295 Standard_Boolean Value(
const math_Vector& X,math_Vector& F) ;
296 Standard_Boolean Derivatives(
const math_Vector& X,math_Matrix& D) ;
297 Standard_Boolean Values(
const math_Vector& X,math_Vector& F,math_Matrix& D) ;
298 Standard_Integer GetStateNumber ();
321 void Set(
const int edgeID,
Adaptor3d_Curve* curve,
const bool isForward );
322 void Set(
const int edgeID,
const gp_XYZ& node1,
const gp_XYZ& node2 );
324 double EndParam(
int i)
const {
return i ? myLast : myFirst; }
326 const gp_XYZ&
NodeXYZ(
int i)
const {
return i ? myNodes[1] : myNodes[0]; }
327 gp_XYZ Point(
const gp_XYZ& theParams )
const;
328 double GetU(
const gp_XYZ& theParams )
const;
336 double myFirst [ 4 ];
340 gp_XY myCorner [ 4 ];
348 void Set(
const int faceID,
const TEdge& edgeU0,
const TEdge& edgeU1 );
349 gp_XY GetUV(
const gp_XYZ& theParams )
const;
350 gp_XYZ Point(
const gp_XYZ& theParams )
const;
351 int GetUInd()
const {
return myCoordInd[ 0 ]; }
352 int GetVInd()
const {
return myCoordInd[ 2 ]; }
353 void GetCoefs(
int i,
const gp_XYZ& theParams,
double& eCoef,
double& vCoef )
const;
354 TFace(): myS(0) { myC2d[0]=myC2d[1]=myC2d[2]=myC2d[3]=0; }
368 enum { SQUARE_DIST = 0, DRV_1, DRV_2, DRV_3 };
369 double distance ()
const {
return sqrt( myValues[ SQUARE_DIST ]); }
370 double funcValue(
double sqDist)
const {
return mySquareFunc ? sqDist : sqrt(sqDist); }
371 bool computeParameters(
const gp_Pnt& thePoint, gp_XYZ& theParams,
const gp_XYZ& theParamsHint);
382 double myValues[ 4 ];
385 TxyzPair my3x3x3GridNodes[ 27 ];
static bool IsVertexID(int theShapeID)
bool EdgePoint(const int theEdgeID, const gp_XYZ &theParams, gp_XYZ &thePoint) const
bool FaceUV(const int theFaceID, const gp_XYZ &theParams, gp_XY &theUV) const
bool VertexPoint(const int theVertexID, gp_XYZ &thePoint) const
static bool IsEdgeID(int theShapeID)
bool FacePoint(const int theFaceID, const gp_XYZ &theParams, gp_XYZ &thePoint) const
double EndParam(int i) const
bool EdgeU(const int theEdgeID, const gp_XYZ &theParams, double &theU) const
double funcValue(double sqDist) const
std::pair< gp_XYZ, gp_XYZ > TxyzPair
static bool IsFaceID(int theShapeID)
static bool IsForwardEdge(const TopoDS_Edge &theEdge, const TopTools_IndexedMapOfOrientedShape &theShapeIDMap)
static int ShapeIndex(int theShapeID)
Adaptor3d_Curve * GetCurve() const
const gp_XYZ & NodeXYZ(int i) const
static int GetCoordIndOnEdge(const int theEdgeID)