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;
126 {
return (theEdgeID < ID_E0y0) ? 1 : (theEdgeID < ID_E00z) ? 2 : 3; }
140 static std::ostream&
DumpShapeID (
const int theBlockShapeID, std::ostream& stream);
152 const TopoDS_Vertex& theVertex000,
153 const TopoDS_Vertex& theVertex001,
154 TopTools_IndexedMapOfOrientedShape& theShapeIDMap );
163 const int theNode000Index,
164 const int theNode001Index,
165 std::vector<const SMDS_MeshNode*>& theOrderedNodes);
171 const TopTools_IndexedMapOfOrientedShape& theShapeIDMap);
176 static bool Insert(
const TopoDS_Shape& theShape,
177 const int theShapeID,
178 TopTools_IndexedMapOfOrientedShape& theShapeIDMap);
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;
229 const std::vector<gp_XYZ>& thePointOnShape,
244 const int theShapeID = ID_Shell,
245 const gp_XYZ& theParamsHint = gp_XYZ(-1,-1,-1));
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 );
277 TopoDS_Vertex theFirstVertex,
278 std::list< TopoDS_Edge >& theEdges,
279 std::list< int > & theNbVertexInWires,
280 const bool theShapeAnalysisAlgo=
false);
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) ;
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 ];
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); }
382 double myValues[ 4 ];
void Set(const int edgeID, const gp_XYZ &node1, const gp_XYZ &node2)
void Set(const int edgeID, Adaptor3d_Curve *curve, const bool isForward)
double EndParam(int i) const
double GetU(const gp_XYZ &theParams) const
Adaptor3d_Curve * GetCurve() const
gp_XYZ Point(const gp_XYZ &theParams) const
const gp_XYZ & NodeXYZ(int i) const
gp_XYZ Point(const gp_XYZ &theParams) const
gp_XY GetUV(const gp_XYZ &theParams) const
void GetCoefs(int i, const gp_XYZ &theParams, double &eCoef, double &vCoef) const
void Set(const int faceID, Adaptor3d_Surface *S, Adaptor2d_Curve2d *c2d[4], const bool isForward[4])
void Set(const int faceID, const TEdge &edgeU0, const TEdge &edgeU1)
bool FaceUV(const int theFaceID, const gp_XYZ &theParams, gp_XY &theUV) const
static double * GetShapeCoef(const int theShapeID)
Standard_Integer NbEquations() const
static void GetFaceEdgesIDs(const int faceID, std::vector< int > &edgeVec)
Standard_Boolean Value(const math_Vector &X, math_Vector &F)
static int GetShapeIDByParams(const gp_XYZ &theParams)
static bool IsVertexID(int theShapeID)
bool LoadBlockShapes(const TopTools_IndexedMapOfOrientedShape &theShapeIDMap)
Standard_Boolean Derivatives(const math_Vector &X, math_Matrix &D)
static int GetCoordIndOnEdge(const int theEdgeID)
void init()
Call it after geometry initialisation.
bool LoadBlockShapes(const TopoDS_Shell &theShell, const TopoDS_Vertex &theVertex000, const TopoDS_Vertex &theVertex001, TopTools_IndexedMapOfOrientedShape &theShapeIDMap)
static int GetOrderedEdges(const TopoDS_Face &theFace, TopoDS_Vertex theFirstVertex, std::list< TopoDS_Edge > &theEdges, std::list< int > &theNbVertexInWires, const bool theShapeAnalysisAlgo=false)
bool EdgeU(const int theEdgeID, const gp_XYZ &theParams, double &theU) const
double funcValue(double sqDist) const
bool FacePoint(const int theFaceID, const gp_XYZ &theParams, gp_XYZ &thePoint) const
Standard_Boolean Values(const math_Vector &X, math_Vector &F, math_Matrix &D)
static void GetEdgeVertexIDs(const int edgeID, std::vector< int > &vertexVec)
static bool FindBlockShapes(const TopoDS_Shell &theShell, const TopoDS_Vertex &theVertex000, const TopoDS_Vertex &theVertex001, TopTools_IndexedMapOfOrientedShape &theShapeIDMap)
bool VertexPoint(const int theVertexID, gp_XYZ &thePoint) const
static int ShapeIndex(int theShapeID)
bool ComputeParameters(const gp_Pnt &thePoint, gp_XYZ &theParams, const int theShapeID=ID_Shell, const gp_XYZ &theParamsHint=gp_XYZ(-1,-1,-1))
static bool IsFaceID(int theShapeID)
bool ShellPoint(const gp_XYZ &theParams, gp_XYZ &thePoint) const
bool LoadFace(const TopoDS_Face &theFace, const int theFaceID, const TopTools_IndexedMapOfOrientedShape &theShapeIDMap)
std::pair< gp_XYZ, gp_XYZ > TxyzPair
Standard_Integer NbVariables() const
static bool Insert(const TopoDS_Shape &theShape, const int theShapeID, TopTools_IndexedMapOfOrientedShape &theShapeIDMap)
static bool ShellPoint(const gp_XYZ &theParams, const std::vector< gp_XYZ > &thePointOnShape, gp_XYZ &thePoint)
bool EdgeParameters(const int theEdgeID, const double theU, gp_XYZ &theParams)
static bool IsForwardEdge(const TopoDS_Edge &theEdge, const TopTools_IndexedMapOfOrientedShape &theShapeIDMap)
static bool IsEdgeID(int theShapeID)
bool LoadMeshBlock(const SMDS_MeshVolume *theVolume, const int theNode000Index, const int theNode001Index, std::vector< const SMDS_MeshNode * > &theOrderedNodes)
Standard_Integer GetStateNumber()
bool computeParameters(const gp_Pnt &thePoint, gp_XYZ &theParams, const gp_XYZ &theParamsHint)
bool EdgePoint(const int theEdgeID, const gp_XYZ &theParams, gp_XYZ &thePoint) const
bool VertexParameters(const int theVertexID, gp_XYZ &theParams)
static std::ostream & DumpShapeID(const int theBlockShapeID, std::ostream &stream)