27#ifndef SMESH_Block_HeaderFile
28#define SMESH_Block_HeaderFile
37#include <TopTools_IndexedMapOfOrientedShape.hxx>
38#include <TopoDS_Edge.hxx>
39#include <TopoDS_Face.hxx>
40#include <TopoDS_Shell.hxx>
41#include <TopoDS_Vertex.hxx>
44#include <math_FunctionSetWithDerivatives.hxx>
71 ID_V000 = 1, ID_V100, ID_V010, ID_V110, ID_V001, ID_V101, ID_V011, ID_V111,
77 ID_Fxy0, ID_Fxy1, ID_Fx0z, ID_Fx1z,
ID_F0yz, ID_F1yz,
83 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));
251 bool VertexParameters(
const int theVertexID, gp_XYZ& theParams);
254 bool EdgeParameters(
const int theEdgeID,
const double theU, gp_XYZ& theParams);
257 void SetTolerance(
const double tol);
263 bool IsToleranceReached()
const;
275 const TopTools_IndexedMapOfOrientedShape& theShapeIDMap) {
276 int v1ID = theShapeIDMap.FindIndex( TopExp::FirstVertex( theEdge ).Oriented( TopAbs_FORWARD ));
277 int v2ID = theShapeIDMap.FindIndex( TopExp::LastVertex( theEdge ).Oriented( TopAbs_FORWARD ));
278 return ( v1ID < v2ID );
282 static int GetOrderedEdges (
const TopoDS_Face& theFace,
283 std::list< TopoDS_Edge >& theEdges,
284 std::list< int > & theNbEdgesInWires,
285 TopoDS_Vertex theFirstVertex=TopoDS_Vertex(),
286 const bool theShapeAnalysisAlgo=
false);
299 Standard_Integer NbVariables()
const;
300 Standard_Integer NbEquations()
const;
301 Standard_Boolean Value(
const math_Vector& X,math_Vector& F) ;
302 Standard_Boolean Derivatives(
const math_Vector& X,math_Matrix&
D) ;
303 Standard_Boolean Values(
const math_Vector& X,math_Vector& F,math_Matrix&
D) ;
304 Standard_Integer GetStateNumber ();
327 void Set(
const int edgeID,
Adaptor3d_Curve* curve,
const bool isForward );
328 void Set(
const int edgeID,
const gp_XYZ& node1,
const gp_XYZ& node2 );
330 double EndParam(
int i)
const {
return i ? myLast : myFirst; }
332 const gp_XYZ&
NodeXYZ(
int i)
const {
return i ? myNodes[1] : myNodes[0]; }
333 gp_XYZ Point(
const gp_XYZ& theParams )
const;
334 double GetU(
const gp_XYZ& theParams )
const;
342 double myFirst [ 4 ];
346 gp_XY myCorner [ 4 ];
354 void Set(
const int faceID,
const TEdge& edgeU0,
const TEdge& edgeU1 );
355 gp_XY GetUV(
const gp_XYZ& theParams )
const;
356 gp_XYZ Point(
const gp_XYZ& theParams )
const;
357 int GetUInd()
const {
return myCoordInd[ 0 ]; }
358 int GetVInd()
const {
return myCoordInd[ 2 ]; }
359 void GetCoefs(
int i,
const gp_XYZ& theParams,
double& eCoef,
double& vCoef )
const;
361 bool IsUVInQuad(
const gp_XY& uv,
362 const gp_XYZ& param0,
const gp_XYZ& param1,
363 const gp_XYZ& param2,
const gp_XYZ& param3 )
const;
364 gp_XY GetUVRange()
const;
365 TFace(): myS(0) { myC2d[0]=myC2d[1]=myC2d[2]=myC2d[3]=0; }
379 enum { SQUARE_DIST = 0,
DRV_1, DRV_2, DRV_3 };
380 double distance ()
const {
return sqrt( myValues[ SQUARE_DIST ]); }
381 double funcValue(
double sqDist)
const {
return mySquareFunc ? sqDist : sqrt(sqDist); }
382 bool computeParameters(
const gp_Pnt& thePoint, gp_XYZ& theParams,
const gp_XYZ& theParamsHint,
int);
383 void refineParametersOnFace(
const gp_Pnt& thePoint, gp_XYZ& theParams,
int theFaceID );
384 bool findUVByHalfDivision(
const gp_Pnt& thePoint,
const gp_XY& theUV,
385 const TFace& tface, gp_XYZ& theParams);
386 bool findUVAround(
const gp_Pnt& thePoint,
const gp_XY& theUV,
387 const TFace& tface, gp_XYZ& theParams,
int nbGetWorstLimit );
388 bool saveBetterSolution(
const gp_XYZ& theNewParams, gp_XYZ& theParams,
double sqDistance );
399 double myValues[ 4 ];
#define SMESHUtils_EXPORT
Definition: SMESH_Utils.hxx:37
by Hexahedron(ijk) algorithm to renumber mesh of a block to be structured-like
Definition: SMDS_MeshNode.hxx:36
Mesh volume.
Definition: SMDS_MeshVolume.hxx:40
Definition: SMESH_Block.hxx:319
double myFirst
Definition: SMESH_Block.hxx:321
double EndParam(int i) const
Definition: SMESH_Block.hxx:330
Adaptor3d_Curve * GetCurve() const
Definition: SMESH_Block.hxx:329
double myLast
Definition: SMESH_Block.hxx:322
const gp_XYZ & NodeXYZ(int i) const
Definition: SMESH_Block.hxx:332
TEdge()
Definition: SMESH_Block.hxx:335
int CoordInd() const
Definition: SMESH_Block.hxx:331
int myCoordInd
Definition: SMESH_Block.hxx:320
Adaptor3d_Curve * myC3d
Definition: SMESH_Block.hxx:323
Definition: SMESH_Block.hxx:339
Adaptor3d_Surface * myS
Definition: SMESH_Block.hxx:348
int GetVInd() const
Definition: SMESH_Block.hxx:358
TFace()
Definition: SMESH_Block.hxx:365
int GetUInd() const
Definition: SMESH_Block.hxx:357
const Adaptor3d_Surface * Surface() const
Definition: SMESH_Block.hxx:360
Definition: SMESH_Block.hxx:63
bool FaceUV(const int theFaceID, const gp_XYZ &theParams, gp_XY &theUV) const
Definition: SMESH_Block.hxx:219
static int NbEdges()
Definition: SMESH_Block.hxx:93
bool myGridComputed
Definition: SMESH_Block.hxx:403
int myFaceIndex
Definition: SMESH_Block.hxx:390
int myNbIterations
Definition: SMESH_Block.hxx:392
gp_XYZ myParam
Definition: SMESH_Block.hxx:398
double myTolerance
Definition: SMESH_Block.hxx:394
static bool IsVertexID(int theShapeID)
Definition: SMESH_Block.hxx:98
double GetTolerance() const
Definition: SMESH_Block.hxx:260
static int NbVertices()
Definition: SMESH_Block.hxx:92
static int GetCoordIndOnEdge(const int theEdgeID)
Definition: SMESH_Block.hxx:125
bool EdgeU(const int theEdgeID, const gp_XYZ &theParams, double &theU) const
Definition: SMESH_Block.hxx:207
bool mySquareFunc
Definition: SMESH_Block.hxx:395
double funcValue(double sqDist) const
Definition: SMESH_Block.hxx:381
double myFaceParam
Definition: SMESH_Block.hxx:391
bool FacePoint(const int theFaceID, const gp_XYZ &theParams, gp_XYZ &thePoint) const
Definition: SMESH_Block.hxx:213
double mySumDist
Definition: SMESH_Block.hxx:393
bool VertexPoint(const int theVertexID, gp_XYZ &thePoint) const
Definition: SMESH_Block.hxx:195
static int NbSubShapes()
Definition: SMESH_Block.hxx:95
static int ShapeIndex(int theShapeID)
Definition: SMESH_Block.hxx:107
static bool IsFaceID(int theShapeID)
Definition: SMESH_Block.hxx:104
TShapeID
Definition: SMESH_Block.hxx:65
@ ID_Ex00
Definition: SMESH_Block.hxx:73
@ ID_F0yz
Definition: SMESH_Block.hxx:77
@ ID_Shell
Definition: SMESH_Block.hxx:79
@ ID_E0y0
Definition: SMESH_Block.hxx:74
@ ID_E00z
Definition: SMESH_Block.hxx:75
double DistanceReached() const
Definition: SMESH_Block.hxx:266
std::pair< gp_XYZ, gp_XYZ > TxyzPair
Definition: SMESH_Block.hxx:401
@ DRV_1
Definition: SMESH_Block.hxx:379
static bool IsForwardEdge(const TopoDS_Edge &theEdge, const TopTools_IndexedMapOfOrientedShape &theShapeIDMap)
Definition: SMESH_Block.hxx:274
static bool IsEdgeID(int theShapeID)
Definition: SMESH_Block.hxx:101
gp_XYZ myPoint
Definition: SMESH_Block.hxx:397
static int NbFaces()
Definition: SMESH_Block.hxx:94
bool EdgePoint(const int theEdgeID, const gp_XYZ &theParams, gp_XYZ &thePoint) const
Definition: SMESH_Block.hxx:201
double distance() const
Definition: SMESH_Block.hxx:380