27 #ifndef SMESH_MesherHelper_HeaderFile
28 #define SMESH_MesherHelper_HeaderFile
34 #include <Geom_Surface.hxx>
35 #include <ShapeAnalysis_Surface.hxx>
36 #include <TopoDS_Face.hxx>
37 #include <TopoDS_Shape.hxx>
38 #include <gp_Pnt2d.hxx>
43 class GeomAPI_ProjectPointOnCurve;
44 class GeomAPI_ProjectPointOnSurf;
50 typedef std::map<SMESH_TLink, const SMDS_MeshNode*>
TLinkNodeMap;
51 typedef std::map<SMESH_TLink, const SMDS_MeshNode*>::iterator
ItTLinkNode;
59 typedef gp_XY (*
xyFunPtr)(
const gp_XY& uv1,
const gp_XY& uv2);
89 const bool nullSubMeshRes =
true);
105 const TopoDS_Face& theFace,
106 const std::list<TopoDS_Edge>& theBaseSide,
113 const TopoDS_Face& theFace,
114 const TopoDS_Edge& theBaseEdge,
126 bool checkUV =
false,
144 static TopoDS_Shape GetSubShapeByNode(
const SMDS_MeshNode* node,
153 static inline int WrapIndex(
int ind,
const int nbNodes) {
154 return (( ind %= nbNodes ) < 0 ) ? ind + nbNodes : ind;
178 inline static gp_XY calcTFI(
double x,
double y,
179 const gp_XY& a0,
const gp_XY& a1,
const gp_XY& a2,
const gp_XY& a3,
180 const gp_XY& p0,
const gp_XY& p1,
const gp_XY& p2,
const gp_XY& p3);
185 inline static gp_XYZ calcTFI(
double x,
double y,
186 const gp_XYZ& a0,
const gp_XYZ& a1,
const gp_XYZ& a2,
const gp_XYZ& a3,
187 const gp_XYZ& p0,
const gp_XYZ& p1,
const gp_XYZ& p2,
const gp_XYZ& p3);
195 static int Count(
const TopoDS_Shape& shape,
196 const TopAbs_ShapeEnum type,
197 const bool ignoreSame);
202 static int NbAncestors(
const TopoDS_Shape& shape,
204 TopAbs_ShapeEnum ancestorType=TopAbs_SHAPE);
210 TopAbs_ShapeEnum ancestorType,
211 const TopoDS_Shape* container = 0);
215 static TopoDS_Shape GetCommonAncestor(
const TopoDS_Shape& shape1,
216 const TopoDS_Shape& shape2,
218 TopAbs_ShapeEnum ancestorType);
222 static TopAbs_Orientation GetSubShapeOri(
const TopoDS_Shape& shape,
223 const TopoDS_Shape& subShape);
225 static bool IsSubShape(
const TopoDS_Shape& shape,
const TopoDS_Shape& mainShape );
229 static bool IsBlock(
const TopoDS_Shape& shape );
231 static double MaxTolerance(
const TopoDS_Shape& shape );
233 static double GetAngle(
const TopoDS_Edge & E1,
const TopoDS_Edge & E2,
234 const TopoDS_Face & F,
const TopoDS_Vertex & V,
235 gp_Vec* faceNormal=0);
237 static bool IsClosedEdge(
const TopoDS_Edge& anEdge );
239 static TopoDS_Vertex IthVertex(
const bool is2nd, TopoDS_Edge anEdge,
const bool CumOri=
true );
241 static TopAbs_ShapeEnum GetGroupType(
const TopoDS_Shape& group,
242 const bool avoidCompound=
false);
245 const TopoDS_Shape& shape,
265 bool IsQuadraticSubMesh(
const TopoDS_Shape& theShape);
270 void SetIsQuadratic(
const bool theBuildQuadratic)
271 { myCreateQuadratic = theBuildQuadratic; }
276 void SetIsBiQuadratic(
const bool theBuildBiQuadratic)
277 { myCreateBiQuadratic = theBuildBiQuadratic; }
287 bool IsReversedSubMesh (
const TopoDS_Face& theFace);
306 bool SetElementsOnShape(
bool toSet)
307 {
bool res = mySetElemOnShape; mySetElemOnShape = toSet;
return res; }
312 void SetSubShape(
const int subShapeID);
313 void SetSubShape(
const TopoDS_Shape& subShape);
333 int ShapeToIndex(
const TopoDS_Shape& S )
const;
345 const bool force3d =
true);
353 const bool force3d =
false);
362 const bool force3d =
false);
366 SMDS_MeshFace* AddPolygonalFace (
const std::vector<const SMDS_MeshNode*>& nodes,
368 const bool force3d =
false);
377 const bool force3d =
true);
387 const bool force3d =
true);
398 const bool force3d =
true);
411 bool force3d =
true);
429 bool force3d =
true);
434 SMDS_MeshVolume* AddPolyhedralVolume (
const std::vector<const SMDS_MeshNode*>& nodes,
435 const std::vector<int>& quantities,
437 const bool force3d =
true);
444 void ToFixNodeParameters(
bool toFix);
449 double GetNodeU(
const TopoDS_Edge& theEdge,
452 bool* check=0)
const;
458 gp_XY GetNodeUV(
const TopoDS_Face& F,
461 bool* check=0)
const;
468 bool CheckNodeUV(
const TopoDS_Face& F,
472 const bool force=
false,
473 double distXYZ[4]=0)
const;
480 bool CheckNodeU(
const TopoDS_Edge& E,
484 const bool force=
false,
485 double distXYZ[4]=0)
const;
489 static gp_XY GetMiddleUV(
const Handle(Geom_Surface)& surface,
495 static gp_XY GetCenterUV(
const gp_XY& uv1,
509 #define gp_XY_FunPtr(meth) \
510 static gp_XY __gpXY_##meth (const gp_XY& uv1, const gp_XY& uv2) { return uv1.meth( uv2 ); } \
511 static xyFunPtr gp_XY_##meth = & __gpXY_##meth
518 static gp_XY ApplyIn2D(
Handle(Geom_Surface) surface,
522 const bool resultInPeriod=
true);
530 void AdjustByPeriod(
const TopoDS_Face& face, gp_XY uv[],
const int nbUV );
539 bool GetNodeUVneedInFaceNode(
const TopoDS_Face& F = TopoDS_Face())
const;
544 GeomAPI_ProjectPointOnSurf& GetProjector(
const TopoDS_Face& F,
545 TopLoc_Location& loc,
546 double tol=0 )
const;
550 Handle(ShapeAnalysis_Surface) GetSurface(const TopoDS_Face& F ) const;
559 bool IsDegenShape(const
int subShape)
const
560 {
return myDegenShapeIds.find( subShape ) != myDegenShapeIds.end(); }
576 bool IsSeamShape(
const int subShape)
const
577 {
return mySeamShapeIds.find( subShape ) != mySeamShapeIds.end(); }
586 bool IsSeamShape(
const TopoDS_Shape& subShape)
const
592 bool IsRealSeam(
const int subShape)
const
593 {
return mySeamShapeIds.find( -subShape ) != mySeamShapeIds.end(); }
598 bool IsRealSeam(
const TopoDS_Shape& subShape)
const
599 {
return IsRealSeam( ShapeToIndex( subShape )); }
606 bool HasSeam()
const {
return !mySeamShapeIds.empty(); }
612 bool HasRealSeam()
const {
return HasSeam() && ( *mySeamShapeIds.begin() < 0 ); }
621 double GetOtherParam(
const double param)
const;
625 int IsOnSeam(
const gp_XY& uv)
const;
639 TopAbs_ShapeEnum expectedSupport=TopAbs_SHAPE);
671 std::pair<int, TopAbs_ShapeEnum> GetMediumPos(
const SMDS_MeshNode* n1,
673 const bool useCurSubShape=
false,
674 TopAbs_ShapeEnum expectedSupport=TopAbs_SHAPE);
685 { myTLinkNodeMap.insert(aMap.begin(), aMap.end()); }
702 MType IsQuadraticMesh();
706 static void WriteShape(
const TopoDS_Shape& s);
717 gp_Pnt2d getUVOnSeam(
const gp_Pnt2d& uv1,
const gp_Pnt2d& uv2 )
const;
723 double getFaceMaxTol(
const TopoDS_Shape& face )
const;
732 struct TBiQuad:
public std::pair<int, std::pair<int, int> >
743 if ( n4 ) s.insert(n4);
744 TIDSortedNodeSet::iterator n = s.begin();
745 first = (*n++)->GetID();
746 second.first = (*n++)->GetID();
747 second.second = (*n++)->GetID();
757 double myPar1[2], myPar2[2];
762 typedef std::map< int, Handle(ShapeAnalysis_Surface)>
TID2Surface;
779 bool toCheckPosOnShape(
int shapeID )
const;
780 void setPosOnShapeValidity(
int shapeID,
bool ok )
const;
786 const gp_XY& a0,
const gp_XY& a1,
const gp_XY& a2,
const gp_XY& a3,
787 const gp_XY& p0,
const gp_XY& p1,
const gp_XY& p2,
const gp_XY& p3)
790 ((1 - y) * p0 + x * p1 + y * p2 + (1 - x) * p3 ) -
791 ((1 - x) * (1 - y) * a0 + x * (1 - y) * a1 + x * y * a2 + (1 - x) * y * a3);
796 const gp_XYZ& a0,
const gp_XYZ& a1,
const gp_XYZ& a2,
const gp_XYZ& a3,
797 const gp_XYZ& p0,
const gp_XYZ& p1,
const gp_XYZ& p2,
const gp_XYZ& p3)
800 ((1 - y) * p0 + x * p1 + y * p2 + (1 - x) * p3 ) -
801 ((1 - x) * (1 - y) * a0 + x * (1 - y) * a1 + x * y * a2 + (1 - x) * y * a3);