27 #ifndef SMESH_MesherHelper_HeaderFile
28 #define SMESH_MesherHelper_HeaderFile
35 #include <Geom_Surface.hxx>
36 #include <ShapeAnalysis_Surface.hxx>
37 #include <TopoDS_Face.hxx>
38 #include <TopoDS_Shape.hxx>
39 #include <gp_Pnt2d.hxx>
44 class GeomAPI_ProjectPointOnCurve;
45 class GeomAPI_ProjectPointOnSurf;
59 typedef std::map<SMESH_TLink, const SMDS_MeshNode*>::iterator
ItTLinkNode;
67 typedef gp_XY (*
xyFunPtr)(
const gp_XY& uv1,
const gp_XY& uv2);
97 const bool nullSubMeshRes =
true);
113 const TopoDS_Face& theFace,
114 const std::list<TopoDS_Edge>& theBaseSide,
121 const TopoDS_Face& theFace,
122 const TopoDS_Edge& theBaseEdge,
141 bool checkUV =
false,
159 static TopoDS_Shape GetSubShapeByNode(
const SMDS_MeshNode* node,
168 static inline int WrapIndex(
int ind,
const int nbNodes) {
169 return (( ind %= nbNodes ) < 0 ) ? ind + nbNodes : ind;
193 inline static gp_XY calcTFI(
double x,
double y,
194 const gp_XY& a0,
const gp_XY& a1,
const gp_XY& a2,
const gp_XY& a3,
195 const gp_XY& p0,
const gp_XY& p1,
const gp_XY& p2,
const gp_XY& p3);
200 inline static gp_XYZ calcTFI(
double x,
double y,
201 const gp_XYZ& a0,
const gp_XYZ& a1,
const gp_XYZ& a2,
const gp_XYZ& a3,
202 const gp_XYZ& p0,
const gp_XYZ& p1,
const gp_XYZ& p2,
const gp_XYZ& p3);
210 static int Count(
const TopoDS_Shape& shape,
211 const TopAbs_ShapeEnum type,
212 const bool ignoreSame);
217 static int NbAncestors(
const TopoDS_Shape& shape,
219 TopAbs_ShapeEnum ancestorType=TopAbs_SHAPE);
225 TopAbs_ShapeEnum ancestorType,
226 const TopoDS_Shape* container = 0);
230 static TopoDS_Shape GetCommonAncestor(
const TopoDS_Shape& shape1,
231 const TopoDS_Shape& shape2,
233 TopAbs_ShapeEnum ancestorType);
237 static TopAbs_Orientation GetSubShapeOri(
const TopoDS_Shape& shape,
238 const TopoDS_Shape& subShape);
240 static bool IsSubShape(
const TopoDS_Shape& shape,
const TopoDS_Shape& mainShape );
244 static bool IsBlock(
const TopoDS_Shape& shape );
246 static double MaxTolerance(
const TopoDS_Shape& shape );
248 static double GetAngle(
const TopoDS_Edge & E1,
const TopoDS_Edge & E2,
249 const TopoDS_Face & F,
const TopoDS_Vertex & V,
250 gp_Vec* faceNormal=0);
252 static bool IsClosedEdge(
const TopoDS_Edge& anEdge );
254 static TopoDS_Vertex IthVertex(
const bool is2nd, TopoDS_Edge anEdge,
const bool CumOri=
true );
256 static TopAbs_ShapeEnum GetGroupType(
const TopoDS_Shape& group,
257 const bool avoidCompound=
false);
260 const TopoDS_Shape& shape,
280 bool IsQuadraticSubMesh(
const TopoDS_Shape& theShape);
286 { myCreateQuadratic = theBuildQuadratic; }
292 { myCreateBiQuadratic = theBuildBiQuadratic; }
302 bool IsReversedSubMesh (
const TopoDS_Face& theFace);
322 {
bool res = mySetElemOnShape; mySetElemOnShape = toSet;
return res; }
327 void SetSubShape(
const int subShapeID);
328 void SetSubShape(
const TopoDS_Shape& subShape);
348 int ShapeToIndex(
const TopoDS_Shape& S )
const;
353 SMDS_MeshNode*
AddNode(
double x,
double y,
double z, smIdType ID = 0,
double u=0.,
double v=0.);
359 const smIdType
id = 0,
360 const bool force3d =
true);
368 const bool force3d =
false);
376 const smIdType
id = 0,
377 const bool force3d =
false);
381 SMDS_MeshFace* AddPolygonalFace (
const std::vector<const SMDS_MeshNode*>& nodes,
382 const smIdType
id = 0,
383 const bool force3d =
false);
391 const smIdType
id = 0,
392 const bool force3d =
true);
401 const smIdType
id = 0,
402 const bool force3d =
true);
412 const smIdType
id = 0,
413 const bool force3d =
true);
425 const smIdType
id = 0,
426 bool force3d =
true);
443 const smIdType
id = 0,
444 bool force3d =
true);
449 SMDS_MeshVolume* AddPolyhedralVolume (
const std::vector<const SMDS_MeshNode*>& nodes,
450 const std::vector<int>& quantities,
452 const bool force3d =
true);
459 void ToFixNodeParameters(
bool toFix);
464 double GetNodeU(
const TopoDS_Edge& theEdge,
467 bool* check=0)
const;
473 gp_XY GetNodeUV(
const TopoDS_Face& F,
476 bool* check=0)
const;
483 bool CheckNodeUV(
const TopoDS_Face& F,
487 const bool force=
false,
488 double distXYZ[4]=0)
const;
495 bool CheckNodeU(
const TopoDS_Edge& E,
499 const bool force=
false,
500 double distXYZ[4]=0)
const;
504 static gp_XY GetMiddleUV(
const Handle(Geom_Surface)& surface,
510 static gp_XY GetCenterUV(
const gp_XY& uv1,
524 #define gp_XY_FunPtr(meth) \
525 static gp_XY __gpXY_##meth (const gp_XY& uv1, const gp_XY& uv2) { return uv1.meth( uv2 ); } \
526 static xyFunPtr gp_XY_##meth = & __gpXY_##meth
537 const bool resultInPeriod=
true);
545 void AdjustByPeriod(
const TopoDS_Face& face, gp_XY uv[],
const int nbUV );
554 bool GetNodeUVneedInFaceNode(
const TopoDS_Face& F = TopoDS_Face())
const;
559 GeomAPI_ProjectPointOnSurf& GetProjector(
const TopoDS_Face& F,
560 TopLoc_Location& loc,
561 double tol=0 )
const;
565 GeomAPI_ProjectPointOnSurf& GetProjector(
const TopoDS_Face& F,
566 double tol=0 )
const;
570 GeomAPI_ProjectPointOnCurve& GetPCProjector(
const TopoDS_Edge& E )
const;
574 Handle(ShapeAnalysis_Surface) GetSurface(
const TopoDS_Face& F )
const;
584 {
return myDegenShapeIds.find( subShape ) != myDegenShapeIds.end(); }
607 {
return mySeamShapeIds.find( subShape ) != mySeamShapeIds.end(); }
617 {
return IsSeamShape( ShapeToIndex( subShape )); }
623 {
return mySeamShapeIds.find( -subShape ) != mySeamShapeIds.end(); }
629 {
return IsRealSeam( ShapeToIndex( subShape )); }
636 bool HasSeam()
const {
return !mySeamShapeIds.empty(); }
642 bool HasRealSeam()
const {
return HasSeam() && ( *mySeamShapeIds.begin() < 0 ); }
648 size_t NbRealSeam()
const;
657 double GetPeriod(
int perioIndex)
const {
return myPar2[ perioIndex-1 ] - myPar1[ perioIndex-1 ]; }
661 double GetOtherParam(
const double param)
const;
665 int IsOnSeam(
const gp_XY& uv)
const;
679 TopAbs_ShapeEnum expectedSupport=TopAbs_SHAPE);
711 std::pair<int, TopAbs_ShapeEnum> GetMediumPos(
const SMDS_MeshNode* n1,
713 const bool useCurSubShape=
false,
714 TopAbs_ShapeEnum expectedSupport=TopAbs_SHAPE);
725 { myTLinkNodeMap.insert(aMap.begin(), aMap.end()); }
741 enum MType{ LINEAR, QUADRATIC, COMP };
742 MType IsQuadraticMesh();
746 static void WriteShape(
const TopoDS_Shape& s);
757 gp_Pnt2d getUVOnSeam(
const gp_Pnt2d& uv1,
const gp_Pnt2d& uv2 )
const;
763 double getFaceMaxTol(
const TopoDS_Shape& face )
const;
772 struct TBiQuad:
public std::pair<smIdType, std::pair<smIdType, smIdType> >
783 if ( n4 ) s.insert(n4);
784 TIDSortedNodeSet::iterator n = s.begin();
785 first = (*n++)->GetID();
786 second.first = (*n++)->GetID();
787 second.second = (*n++)->GetID();
797 double myPar1[2], myPar2[2];
819 bool toCheckPosOnShape(
int shapeID )
const;
820 void setPosOnShapeValidity(
int shapeID,
bool ok )
const;
826 const gp_XY& a0,
const gp_XY& a1,
const gp_XY& a2,
const gp_XY& a3,
827 const gp_XY& p0,
const gp_XY& p1,
const gp_XY& p2,
const gp_XY& p3)
830 ((1 - y) * p0 + x * p1 + y * p2 + (1 - x) * p3 ) -
831 ((1 - x) * (1 - y) * a0 + x * (1 - y) * a1 + x * y * a2 + (1 - x) * y * a3);
836 const gp_XYZ& a0,
const gp_XYZ& a1,
const gp_XYZ& a2,
const gp_XYZ& a3,
837 const gp_XYZ& p0,
const gp_XYZ& p1,
const gp_XYZ& p2,
const gp_XYZ& p3)
840 ((1 - y) * p0 + x * p1 + y * p2 + (1 - x) * p3 ) -
841 ((1 - x) * (1 - y) * a0 + x * (1 - y) * a1 + x * y * a2 + (1 - x) * y * a3);
SMDSAbs_GeometryType
enumeration for element geometry type
Definition: SMDSAbs_ElementType.hxx:47
SMDSAbs_ElementType
Type (node, edge, face or volume) of elements.
Definition: SMDSAbs_ElementType.hxx:34
@ SMDSAbs_All
Definition: SMDSAbs_ElementType.hxx:35
boost::shared_ptr< SMESH_ComputeError > SMESH_ComputeErrorPtr
Definition: SMESH_ComputeError.hxx:36
static bool IsSubShape(const TopTools_IndexedMapOfShape &theMap, const TopoDS_Shape &theShape)
Definition: SMESH_Controls.cxx:5141
std::map< double, TNodeColumn > TParam2ColumnMap
Definition: SMESH_MesherHelper.hxx:65
SMDS_Iterator< const TopoDS_Shape * > PShapeIterator
Definition: SMESH_MesherHelper.hxx:61
boost::shared_ptr< PShapeIterator > PShapeIteratorPtr
Definition: SMESH_MesherHelper.hxx:62
std::map< SMESH_TLink, const SMDS_MeshNode * > TLinkNodeMap
Definition: SMESH_MesherHelper.hxx:56
gp_XY(* xyFunPtr)(const gp_XY &uv1, const gp_XY &uv2)
Definition: SMESH_MesherHelper.hxx:67
std::vector< const SMDS_MeshNode * > TNodeColumn
Definition: SMESH_MesherHelper.hxx:64
std::map< SMESH_TLink, const SMDS_MeshNode * >::iterator ItTLinkNode
Definition: SMESH_MesherHelper.hxx:59
std::set< const SMDS_MeshNode *, TIDCompare > TIDSortedNodeSet
Definition: SMESH_OctreeNode.hxx:51
#define SMESH_EXPORT
Definition: SMESH_SMESH.hxx:37
Abstract class for iterators.
Definition: SMDS_Iterator.hxx:33
Edge mesh element.
Definition: SMDS_MeshEdge.hxx:36
Mesh face.
Definition: SMDS_MeshFace.hxx:41
Definition: SMDS_MeshNode.hxx:36
Mesh volume.
Definition: SMDS_MeshVolume.hxx:40
Definition: SMESHDS_Hypothesis.hxx:37
Definition: SMESHDS_Mesh.hxx:68
Definition: SMESHDS_SubMesh.hxx:48
Definition: SMESH_Gen.hxx:68
Definition: SMESH_Mesh.hxx:80
It helps meshers to add elements and provides other utilities.
Definition: SMESH_MesherHelper.hxx:84
bool IsRealSeam(const int subShape) const
Return true if an edge or a vertex encounters twice in face wire.
Definition: SMESH_MesherHelper.hxx:622
static gp_XY ApplyIn2D(Handle(Geom_Surface) surface, const gp_XY &uv1, const gp_XY &uv2, xyFunPtr fun, const bool resultInPeriod=true)
Perform given operation on two 2d points in parameric space of given surface.
TopoDS_Shape myShape
Definition: SMESH_MesherHelper.hxx:809
bool IsSeamShape(const TopoDS_Shape &subShape) const
Check if shape is a seam edge or it's vertex.
Definition: SMESH_MesherHelper.hxx:616
std::set< int > mySeamShapeIds
Definition: SMESH_MesherHelper.hxx:796
std::set< int > myDegenShapeIds
Definition: SMESH_MesherHelper.hxx:795
bool GetIsQuadratic() const
Return myCreateQuadratic flag.
Definition: SMESH_MesherHelper.hxx:297
bool HasDegeneratedEdges() const
Check if the shape set through IsQuadraticSubMesh() or SetSubShape() has a degenerated edges.
Definition: SMESH_MesherHelper.hxx:590
int myShapeID
Definition: SMESH_MesherHelper.hxx:811
std::map< int, Handle(ShapeAnalysis_Surface)> TID2Surface
Definition: SMESH_MesherHelper.hxx:802
std::map< int, bool > myNodePosShapesValidity
Definition: SMESH_MesherHelper.hxx:818
std::map< TBiQuad, const SMDS_MeshNode * > myMapWithCentralNode
Definition: SMESH_MesherHelper.hxx:793
bool GetIsBiQuadratic() const
Return myCreateBiQuadratic flag.
Definition: SMESH_MesherHelper.hxx:307
bool SetElementsOnShape(bool toSet)
To set created elements on the shape set by IsQuadraticSubMesh() or the next methods.
Definition: SMESH_MesherHelper.hxx:321
double GetPeriod(int perioIndex) const
Return period in given direction [1,2].
Definition: SMESH_MesherHelper.hxx:657
int myParIndex
Definition: SMESH_MesherHelper.hxx:798
static gp_XY calcTFI(double x, double y, const gp_XY &a0, const gp_XY &a1, const gp_XY &a2, const gp_XY &a3, const gp_XY &p0, const gp_XY &p1, const gp_XY &p2, const gp_XY &p3)
Return UV of a point inside a quadrilateral FACE by it's normalized parameters within a unit quadrang...
Definition: SMESH_MesherHelper.hxx:825
std::map< int, double > myFaceMaxTol
Definition: SMESH_MesherHelper.hxx:800
SMESH_Mesh * myMesh
Definition: SMESH_MesherHelper.hxx:810
TID2ProjectorOnSurf myFace2Projector
Definition: SMESH_MesherHelper.hxx:806
SMESH_MesherHelper(const SMESH_MesherHelper &theOther)
bool mySetElemOnShape
Definition: SMESH_MesherHelper.hxx:815
SMESH_Mesh * GetMesh() const
Definition: SMESH_MesherHelper.hxx:272
bool IsRealSeam(const TopoDS_Shape &subShape) const
Return true if an edge or a vertex encounters twice in face wire.
Definition: SMESH_MesherHelper.hxx:628
TID2ProjectorOnCurve myEdge2Projector
Definition: SMESH_MesherHelper.hxx:807
MType
Check mesh without geometry for: if all elements on this shape are quadratic, quadratic elements will...
Definition: SMESH_MesherHelper.hxx:741
int GetSubShapeID() const
Return ID of the shape set by IsQuadraticSubMesh() or SetSubShape()
Definition: SMESH_MesherHelper.hxx:333
bool HasSeam() const
Check if the shape set through IsQuadraticSubMesh() or SetSubShape() has a seam edge,...
Definition: SMESH_MesherHelper.hxx:636
bool IsSeamShape(const int subShape) const
Check if shape is a seam edge or it's vertex.
Definition: SMESH_MesherHelper.hxx:606
bool myCreateQuadratic
Definition: SMESH_MesherHelper.hxx:813
Handle(ShapeAnalysis_Surface) GetSurface(const TopoDS_Face &F) const
Return a cached ShapeAnalysis_Surface of a FACE.
bool myFixNodeParameters
Definition: SMESH_MesherHelper.hxx:816
TLinkNodeMap myTLinkNodeMap
Definition: SMESH_MesherHelper.hxx:792
std::map< int, GeomAPI_ProjectPointOnSurf * > TID2ProjectorOnSurf
Definition: SMESH_MesherHelper.hxx:803
static int WrapIndex(int ind, const int nbNodes)
Return a valid node index, fixing the given one if necessary.
Definition: SMESH_MesherHelper.hxx:168
void SetIsQuadratic(const bool theBuildQuadratic)
Set order of elements to create without calling IsQuadraticSubMesh()
Definition: SMESH_MesherHelper.hxx:285
bool HasRealSeam() const
Check if the shape set through IsQuadraticSubMesh() or SetSubShape() has a seam edge that encounters ...
Definition: SMESH_MesherHelper.hxx:642
int GetPeriodicIndex() const
Return index of periodic parametric direction of a closed face.
Definition: SMESH_MesherHelper.hxx:653
size_t NbDegeneratedEdges() const
Return a number of degenerated edges in the shape set through IsQuadraticSubMesh() or SetSubShape()
Definition: SMESH_MesherHelper.hxx:596
TID2Surface myFace2Surface
Definition: SMESH_MesherHelper.hxx:805
void SetIsBiQuadratic(const bool theBuildBiQuadratic)
Set myCreateBiQuadratic flag.
Definition: SMESH_MesherHelper.hxx:291
std::map< int, GeomAPI_ProjectPointOnCurve * > TID2ProjectorOnCurve
Definition: SMESH_MesherHelper.hxx:804
bool myCreateBiQuadratic
Definition: SMESH_MesherHelper.hxx:814
const TopoDS_Shape & GetSubShape() const
Return the shape set by IsQuadraticSubMesh() or SetSubShape()
Definition: SMESH_MesherHelper.hxx:337
const TLinkNodeMap & GetTLinkNodeMap() const
Returns myTLinkNodeMap.
Definition: SMESH_MesherHelper.hxx:734
bool IsDegenShape(const int subShape) const
Check if shape is a degenerated edge or it's vertex.
Definition: SMESH_MesherHelper.hxx:583
void AddTLinkNodeMap(const TLinkNodeMap &aMap)
Add many links in my data structure.
Definition: SMESH_MesherHelper.hxx:724
Container of xD mesh elements substituting other ones in the input mesh of an (x+1)D algorithm.
Definition: SMESH_ProxyMesh.hxx:51
Definition: SMESH_subMesh.hxx:61
long AddNode(SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z, const QStringList &theParameters)
Definition: SMESHGUI_NodesDlg.cxx:96
Definition: SMESH_MesherHelper.hxx:773
TBiQuad(const SMDS_MeshNode *n1, const SMDS_MeshNode *n2, const SMDS_MeshNode *n3, const SMDS_MeshNode *n4=0)
Definition: SMESH_MesherHelper.hxx:774