From: eap Date: Mon, 19 Feb 2007 16:25:03 +0000 (+0000) Subject: PAL13504 (Mesh from an imported mesh) X-Git-Tag: V3_2_6a1~83 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f3d960a86aea112c1b1f8dce8465324b7ad71294;p=modules%2Fsmesh.git PAL13504 (Mesh from an imported mesh) add SetElementsOnShape(), redesign --- diff --git a/src/SMESH/SMESH_MesherHelper.cxx b/src/SMESH/SMESH_MesherHelper.cxx index 0d3779585..f85c337fe 100644 --- a/src/SMESH/SMESH_MesherHelper.cxx +++ b/src/SMESH/SMESH_MesherHelper.cxx @@ -44,6 +44,16 @@ #define RETURN_BAD_RESULT(msg) { MESSAGE(msg); return false; } +//================================================================================ +/*! + * \brief Constructor + */ +//================================================================================ + +SMESH_MesherHelper::SMESH_MesherHelper(SMESH_Mesh& theMesh) + : myMesh(&theMesh), myShapeID(-1), myCreateQuadratic(false), mySetElemOnShape(false) +{} + //======================================================================= //function : CheckShape //purpose : @@ -115,7 +125,7 @@ void SMESH_MesherHelper::SetSubShape(const int aShID) if ( aShID == myShapeID ) return; if ( aShID > 1 ) - SetSubShape( GetMesh()->GetMeshDS()->IndexToShape( aShID )); + SetSubShape( GetMeshDS()->IndexToShape( aShID )); else SetSubShape( TopoDS_Shape() ); } @@ -282,7 +292,7 @@ gp_XY SMESH_MesherHelper::GetNodeUV(const TopoDS_Face& F, // edge and recieve value from this pcurve const SMDS_EdgePosition* epos = static_cast(n->GetPosition().get()); - SMESHDS_Mesh* meshDS = GetMesh()->GetMeshDS(); + SMESHDS_Mesh* meshDS = GetMeshDS(); int edgeID = Pos->GetShapeId(); TopoDS_Edge E = TopoDS::Edge(meshDS->IndexToShape(edgeID)); double f, l; @@ -326,7 +336,7 @@ double SMESH_MesherHelper::GetNodeU(const TopoDS_Edge& E, param = epos->GetUParameter(); } else if(Pos->GetTypeOfPosition()==SMDS_TOP_VERTEX) { - SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS(); + SMESHDS_Mesh * meshDS = GetMeshDS(); int vertexID = n->GetPosition()->GetShapeId(); const TopoDS_Vertex& V = TopoDS::Vertex(meshDS->IndexToShape(vertexID)); param = BRep_Tool::Parameter( V, E ); @@ -478,68 +488,108 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1, } //======================================================================= -//function : AddQuadraticEdge -//purpose : +/*! + * Creates a node + */ //======================================================================= -/** - * Special function for creation quadratic edge + +SMDS_MeshNode* SMESH_MesherHelper::AddNode(double x, double y, double z, int ID) +{ + SMESHDS_Mesh * meshDS = GetMeshDS(); + SMDS_MeshNode* node = 0; + if ( ID ) + node = meshDS->AddNodeWithID( x, y, z, ID ); + else + node = meshDS->AddNode( x, y, z ); + if ( mySetElemOnShape && myShapeID > 0 ) { + switch ( myShape.ShapeType() ) { + case TopAbs_SOLID: meshDS->SetNodeInVolume( node, myShapeID); break; + case TopAbs_SHELL: meshDS->SetNodeInVolume( node, myShapeID); break; + case TopAbs_FACE: meshDS->SetNodeOnFace( node, myShapeID); break; + case TopAbs_EDGE: meshDS->SetNodeOnEdge( node, myShapeID); break; + case TopAbs_VERTEX: meshDS->SetNodeOnVertex( node, myShapeID); break; + default: ; + } + } + return node; +} + +//======================================================================= +/*! + * Creates quadratic or linear edge */ -SMDS_QuadraticEdge* SMESH_MesherHelper::AddQuadraticEdge(const SMDS_MeshNode* n1, - const SMDS_MeshNode* n2, - const int id, - const bool force3d) +//======================================================================= + +SMDS_MeshEdge* SMESH_MesherHelper::AddEdge(const SMDS_MeshNode* n1, + const SMDS_MeshNode* n2, + const int id, + const bool force3d) { - SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS(); - - const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); + SMESHDS_Mesh * meshDS = GetMeshDS(); - myCreateQuadratic = true; + SMDS_MeshEdge* edge = 0; + if (myCreateQuadratic) { + const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); + if(id) + edge = meshDS->AddEdgeWithID(n1, n2, n12, id); + else + edge = meshDS->AddEdge(n1, n2, n12); + } + else { + if(id) + edge = meshDS->AddEdgeWithID(n1, n2, id); + else + edge = meshDS->AddEdge(n1, n2); + } - if(id) - return (SMDS_QuadraticEdge*)(meshDS->AddEdgeWithID(n1, n2, n12, id)); - else - return (SMDS_QuadraticEdge*)(meshDS->AddEdge(n1, n2, n12)); + if ( mySetElemOnShape && myShapeID > 0 ) + meshDS->SetMeshElementOnShape( edge, myShapeID ); + + return edge; } -//======================================================================= -//function : AddFace -//purpose : //======================================================================= /*! - * Special function for creation quadratic triangle + * Creates quadratic or linear triangle */ +//======================================================================= + SMDS_MeshFace* SMESH_MesherHelper::AddFace(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2, const SMDS_MeshNode* n3, const int id, const bool force3d) { - SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS(); + SMESHDS_Mesh * meshDS = GetMeshDS(); + SMDS_MeshFace* elem = 0; if(!myCreateQuadratic) { if(id) - return meshDS->AddFaceWithID(n1, n2, n3, id); + elem = meshDS->AddFaceWithID(n1, n2, n3, id); else - return meshDS->AddFace(n1, n2, n3); + elem = meshDS->AddFace(n1, n2, n3); } + else { + const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); + const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); + const SMDS_MeshNode* n31 = GetMediumNode(n3,n1,force3d); - const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); - const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); - const SMDS_MeshNode* n31 = GetMediumNode(n3,n1,force3d); + if(id) + elem = meshDS->AddFaceWithID(n1, n2, n3, n12, n23, n31, id); + else + elem = meshDS->AddFace(n1, n2, n3, n12, n23, n31); + } + if ( mySetElemOnShape && myShapeID > 0 ) + meshDS->SetMeshElementOnShape( elem, myShapeID ); - if(id) - return meshDS->AddFaceWithID(n1, n2, n3, n12, n23, n31, id); - else - return meshDS->AddFace(n1, n2, n3, n12, n23, n31); + return elem; } - -//======================================================================= -//function : AddFace -//purpose : //======================================================================= /*! - * Special function for creation quadratic quadrangle + * Creates quadratic or linear quadrangle */ +//======================================================================= + SMDS_MeshFace* SMESH_MesherHelper::AddFace(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2, const SMDS_MeshNode* n3, @@ -547,33 +597,37 @@ SMDS_MeshFace* SMESH_MesherHelper::AddFace(const SMDS_MeshNode* n1, const int id, const bool force3d) { - SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS(); + SMESHDS_Mesh * meshDS = GetMeshDS(); + SMDS_MeshFace* elem = 0; if(!myCreateQuadratic) { if(id) - return meshDS->AddFaceWithID(n1, n2, n3, n4, id); + elem = meshDS->AddFaceWithID(n1, n2, n3, n4, id); else - return meshDS->AddFace(n1, n2, n3, n4); + elem = meshDS->AddFace(n1, n2, n3, n4); } + else { + const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); + const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); + const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,force3d); + const SMDS_MeshNode* n41 = GetMediumNode(n4,n1,force3d); - const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); - const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); - const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,force3d); - const SMDS_MeshNode* n41 = GetMediumNode(n4,n1,force3d); + if(id) + elem = meshDS->AddFaceWithID(n1, n2, n3, n4, n12, n23, n34, n41, id); + else + elem = meshDS->AddFace(n1, n2, n3, n4, n12, n23, n34, n41); + } + if ( mySetElemOnShape && myShapeID > 0 ) + meshDS->SetMeshElementOnShape( elem, myShapeID ); - if(id) - return meshDS->AddFaceWithID(n1, n2, n3, n4, n12, n23, n34, n41, id); - else - return meshDS->AddFace(n1, n2, n3, n4, n12, n23, n34, n41); + return elem; } - -//======================================================================= -//function : AddVolume -//purpose : //======================================================================= /*! - * Special function for creation quadratic volume + * Creates quadratic or linear volume */ +//======================================================================= + SMDS_MeshVolume* SMESH_MesherHelper::AddVolume(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2, const SMDS_MeshNode* n3, @@ -583,37 +637,43 @@ SMDS_MeshVolume* SMESH_MesherHelper::AddVolume(const SMDS_MeshNode* n1, const int id, const bool force3d) { - SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS(); + SMESHDS_Mesh * meshDS = GetMeshDS(); + SMDS_MeshVolume* elem = 0; if(!myCreateQuadratic) { if(id) - return meshDS->AddVolumeWithID(n1, n2, n3, n4, n5, n6, id); + elem = meshDS->AddVolumeWithID(n1, n2, n3, n4, n5, n6, id); else - return meshDS->AddVolume(n1, n2, n3, n4, n5, n6); + elem = meshDS->AddVolume(n1, n2, n3, n4, n5, n6); } + else { + const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); + const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); + const SMDS_MeshNode* n31 = GetMediumNode(n3,n1,force3d); - const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); - const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); - const SMDS_MeshNode* n31 = GetMediumNode(n3,n1,force3d); + const SMDS_MeshNode* n45 = GetMediumNode(n4,n5,force3d); + const SMDS_MeshNode* n56 = GetMediumNode(n5,n6,force3d); + const SMDS_MeshNode* n64 = GetMediumNode(n6,n4,force3d); - const SMDS_MeshNode* n45 = GetMediumNode(n4,n5,force3d); - const SMDS_MeshNode* n56 = GetMediumNode(n5,n6,force3d); - const SMDS_MeshNode* n64 = GetMediumNode(n6,n4,force3d); + const SMDS_MeshNode* n14 = GetMediumNode(n1,n4,force3d); + const SMDS_MeshNode* n25 = GetMediumNode(n2,n5,force3d); + const SMDS_MeshNode* n36 = GetMediumNode(n3,n6,force3d); - const SMDS_MeshNode* n14 = GetMediumNode(n1,n4,force3d); - const SMDS_MeshNode* n25 = GetMediumNode(n2,n5,force3d); - const SMDS_MeshNode* n36 = GetMediumNode(n3,n6,force3d); + if(id) + elem = meshDS->AddVolumeWithID(n1, n2, n3, n4, n5, n6, + n12, n23, n31, n45, n56, n64, n14, n25, n36, id); + else + elem = meshDS->AddVolume(n1, n2, n3, n4, n5, n6, + n12, n23, n31, n45, n56, n64, n14, n25, n36); + } + if ( mySetElemOnShape && myShapeID > 0 ) + meshDS->SetMeshElementOnShape( elem, myShapeID ); - if(id) - return meshDS->AddVolumeWithID(n1, n2, n3, n4, n5, n6, - n12, n23, n31, n45, n56, n64, n14, n25, n36, id); - else - return meshDS->AddVolume(n1, n2, n3, n4, n5, n6, - n12, n23, n31, n45, n56, n64, n14, n25, n36); + return elem; } //======================================================================= /*! - * Special function for creation quadratic volume + * Creates quadratic or linear volume */ //======================================================================= @@ -624,31 +684,37 @@ SMDS_MeshVolume* SMESH_MesherHelper::AddVolume(const SMDS_MeshNode* n1, const int id, const bool force3d) { - SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS(); + SMESHDS_Mesh * meshDS = GetMeshDS(); + SMDS_MeshVolume* elem = 0; if(!myCreateQuadratic) { if(id) - return meshDS->AddVolumeWithID(n1, n2, n3, n4, id); + elem = meshDS->AddVolumeWithID(n1, n2, n3, n4, id); else - return meshDS->AddVolume(n1, n2, n3, n4); + elem = meshDS->AddVolume(n1, n2, n3, n4); } + else { + const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); + const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); + const SMDS_MeshNode* n31 = GetMediumNode(n3,n1,force3d); - const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); - const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); - const SMDS_MeshNode* n31 = GetMediumNode(n3,n1,force3d); + const SMDS_MeshNode* n14 = GetMediumNode(n1,n4,force3d); + const SMDS_MeshNode* n24 = GetMediumNode(n2,n4,force3d); + const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,force3d); - const SMDS_MeshNode* n14 = GetMediumNode(n1,n4,force3d); - const SMDS_MeshNode* n24 = GetMediumNode(n2,n4,force3d); - const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,force3d); + if(id) + elem = meshDS->AddVolumeWithID(n1, n2, n3, n4, n12, n23, n31, n14, n24, n34, id); + else + elem = meshDS->AddVolume(n1, n2, n3, n4, n12, n23, n31, n14, n24, n34); + } + if ( mySetElemOnShape && myShapeID > 0 ) + meshDS->SetMeshElementOnShape( elem, myShapeID ); - if(id) - return meshDS->AddVolumeWithID(n1, n2, n3, n4, n12, n23, n31, n14, n24, n34, id); - else - return meshDS->AddVolume(n1, n2, n3, n4, n12, n23, n31, n14, n24, n34); + return elem; } //======================================================================= /*! - * Special function for creation quadratic pyramid + * Creates quadratic or linear pyramid */ //======================================================================= @@ -660,37 +726,43 @@ SMDS_MeshVolume* SMESH_MesherHelper::AddVolume(const SMDS_MeshNode* n1, const int id, const bool force3d) { + SMDS_MeshVolume* elem = 0; if(!myCreateQuadratic) { if(id) - return GetMeshDS()->AddVolumeWithID(n1, n2, n3, n4, n5, id); + elem = GetMeshDS()->AddVolumeWithID(n1, n2, n3, n4, n5, id); else - return GetMeshDS()->AddVolume(n1, n2, n3, n4, n5); + elem = GetMeshDS()->AddVolume(n1, n2, n3, n4, n5); } + else { + const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); + const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); + const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,force3d); + const SMDS_MeshNode* n41 = GetMediumNode(n4,n1,force3d); - const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); - const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); - const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,force3d); - const SMDS_MeshNode* n41 = GetMediumNode(n4,n1,force3d); + const SMDS_MeshNode* n15 = GetMediumNode(n1,n5,force3d); + const SMDS_MeshNode* n25 = GetMediumNode(n2,n5,force3d); + const SMDS_MeshNode* n35 = GetMediumNode(n3,n5,force3d); + const SMDS_MeshNode* n45 = GetMediumNode(n4,n5,force3d); - const SMDS_MeshNode* n15 = GetMediumNode(n1,n5,force3d); - const SMDS_MeshNode* n25 = GetMediumNode(n2,n5,force3d); - const SMDS_MeshNode* n35 = GetMediumNode(n3,n5,force3d); - const SMDS_MeshNode* n45 = GetMediumNode(n4,n5,force3d); + if(id) + elem = GetMeshDS()->AddVolumeWithID ( n1, n2, n3, n4, n5, + n12, n23, n34, n41, + n15, n25, n35, n45, + id); + else + elem = GetMeshDS()->AddVolume( n1, n2, n3, n4, n5, + n12, n23, n34, n41, + n15, n25, n35, n45); + } + if ( mySetElemOnShape && myShapeID > 0 ) + GetMeshDS()->SetMeshElementOnShape( elem, myShapeID ); - if(id) - return GetMeshDS()->AddVolumeWithID ( n1, n2, n3, n4, n5, - n12, n23, n34, n41, - n15, n25, n35, n45, - id); - else - return GetMeshDS()->AddVolume( n1, n2, n3, n4, n5, - n12, n23, n34, n41, - n15, n25, n35, n45); + return elem; } //======================================================================= /*! - * Special function for creation of quadratic hexahedron + * Creates quadratic or linear hexahedron */ //======================================================================= @@ -705,37 +777,43 @@ SMDS_MeshVolume* SMESH_MesherHelper::AddVolume(const SMDS_MeshNode* n1, const int id, const bool force3d) { - SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS(); + SMESHDS_Mesh * meshDS = GetMeshDS(); + SMDS_MeshVolume* elem = 0; if(!myCreateQuadratic) { if(id) - return meshDS->AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, id); + elem = meshDS->AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, id); else - return meshDS->AddVolume(n1, n2, n3, n4, n5, n6, n7, n8); + elem = meshDS->AddVolume(n1, n2, n3, n4, n5, n6, n7, n8); } + else { + const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); + const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); + const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,force3d); + const SMDS_MeshNode* n41 = GetMediumNode(n4,n1,force3d); - const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,force3d); - const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,force3d); - const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,force3d); - const SMDS_MeshNode* n41 = GetMediumNode(n4,n1,force3d); + const SMDS_MeshNode* n56 = GetMediumNode(n5,n6,force3d); + const SMDS_MeshNode* n67 = GetMediumNode(n6,n7,force3d); + const SMDS_MeshNode* n78 = GetMediumNode(n7,n8,force3d); + const SMDS_MeshNode* n85 = GetMediumNode(n8,n5,force3d); - const SMDS_MeshNode* n56 = GetMediumNode(n5,n6,force3d); - const SMDS_MeshNode* n67 = GetMediumNode(n6,n7,force3d); - const SMDS_MeshNode* n78 = GetMediumNode(n7,n8,force3d); - const SMDS_MeshNode* n85 = GetMediumNode(n8,n5,force3d); + const SMDS_MeshNode* n15 = GetMediumNode(n1,n5,force3d); + const SMDS_MeshNode* n26 = GetMediumNode(n2,n6,force3d); + const SMDS_MeshNode* n37 = GetMediumNode(n3,n7,force3d); + const SMDS_MeshNode* n48 = GetMediumNode(n4,n8,force3d); - const SMDS_MeshNode* n15 = GetMediumNode(n1,n5,force3d); - const SMDS_MeshNode* n26 = GetMediumNode(n2,n6,force3d); - const SMDS_MeshNode* n37 = GetMediumNode(n3,n7,force3d); - const SMDS_MeshNode* n48 = GetMediumNode(n4,n8,force3d); + if(id) + elem = meshDS->AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, + n12, n23, n34, n41, n56, n67, + n78, n85, n15, n26, n37, n48, id); + else + elem = meshDS->AddVolume(n1, n2, n3, n4, n5, n6, n7, n8, + n12, n23, n34, n41, n56, n67, + n78, n85, n15, n26, n37, n48); + } + if ( mySetElemOnShape && myShapeID > 0 ) + meshDS->SetMeshElementOnShape( elem, myShapeID ); - if(id) - return meshDS->AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, - n12, n23, n34, n41, n56, n67, - n78, n85, n15, n26, n37, n48, id); - else - return meshDS->AddVolume(n1, n2, n3, n4, n5, n6, n7, n8, - n12, n23, n34, n41, n56, n67, - n78, n85, n15, n26, n37, n48); + return elem; } //======================================================================= diff --git a/src/SMESH/SMESH_MesherHelper.hxx b/src/SMESH/SMESH_MesherHelper.hxx index 7cb946aad..4b2cfde5b 100644 --- a/src/SMESH/SMESH_MesherHelper.hxx +++ b/src/SMESH/SMESH_MesherHelper.hxx @@ -55,6 +55,15 @@ class SMESH_MesherHelper public: // ---------- PUBLIC UTILITIES ---------- + /*! + * \brief Returns true if given node is medium + * \param n - node to check + * \param typeToCheck - type of elements containing the node to ask about node status + * \retval bool - check result + */ + static bool IsMedium(const SMDS_MeshNode* node, + const SMDSAbs_ElementType typeToCheck = SMDSAbs_All); + /*! * \brief Load nodes bound to face into a map of node columns * \param theParam2ColumnMap - map of node columns to fill @@ -95,119 +104,72 @@ public: } public: - // ---------- PUBLIC METHODS ---------- + // ---------- PUBLIC INSTANCE METHODS ---------- - /// Empty constructor - SMESH_MesherHelper(SMESH_Mesh& theMesh) - { myMesh=(void *)&theMesh; myCreateQuadratic = false; myShapeID=-1;} + // constructor + SMESH_MesherHelper(SMESH_Mesh& theMesh); - SMESH_Mesh* GetMesh() const { return (SMESH_Mesh*)myMesh; } + SMESH_Mesh* GetMesh() const { return myMesh; } SMESHDS_Mesh* GetMeshDS() const { return GetMesh()->GetMeshDS(); } - /// Copy constructor - //Standard_EXPORT SMESH_MesherHelper (const SMESH_MesherHelper& theOther); - - /// Destructor - //Standard_EXPORT virtual ~SMESH_MesherHelper (); - - /** - * Check submesh for given shape - * Check if all elements on this shape - * are quadratic, if yes => set true to myCreateQuadratic - * (default value is false). Also fill myNLinkNodeMap - * Returns myCreateQuadratic + /*! + * Check submesh for given shape: if all elements on this shape are quadratic, + * quadratic elements will be created. Also fill myNLinkNodeMap */ bool IsQuadraticSubMesh(const TopoDS_Shape& theShape); - /*! - * \brief Returns true if given node is medium - * \param n - node to check - * \param typeToCheck - type of elements containing the node to ask about node status - * \retval bool - check result + * \brief Set order of elements to create without calling IsQuadraticSubMesh() */ - static bool IsMedium(const SMDS_MeshNode* node, - const SMDSAbs_ElementType typeToCheck = SMDSAbs_All); - - /** - * Auxilary function for filling myNLinkNodeMap - */ - void AddNLinkNode(const SMDS_MeshNode* n1, - const SMDS_MeshNode* n2, - const SMDS_MeshNode* n12); - - /** - * Auxilary function for filling myNLinkNodeMap + void SetIsQuadratic(const bool theBuildQuadratic) + { myCreateQuadratic = theBuildQuadratic; } + /*! + * \brief Return myCreateQuadratic flag */ - void AddNLinkNodeMap(const NLinkNodeMap& aMap) - { myNLinkNodeMap.insert(aMap.begin(), aMap.end()); } + bool GetIsQuadratic() const { return myCreateQuadratic; } - /** - * Returns myNLinkNodeMap + /*! + * \brief To set created elements on the shape set by IsQuadraticSubMesh() + * or the next methods. By defaul elements are not set on the shape */ - const NLinkNodeMap& GetNLinkNodeMap() { return myNLinkNodeMap; } + void SetElementsOnShape(bool toSet) { mySetElemOnShape = toSet; } /*! - * \brief Return node UV on face - * \param F - the face - * \param n - the node - * \param inFaceNode - a node of element being created located inside a face - * \retval gp_XY - resulting UV - * - * Auxilary function called form GetMediumNode() + * \brief Set shape to make elements on without calling IsQuadraticSubMesh() */ - gp_XY GetNodeUV(const TopoDS_Face& F, - const SMDS_MeshNode* n, - const SMDS_MeshNode* inFaceNode=0) const; - + void SetSubShape(const int subShapeID);//!==SMESHDS_Mesh::ShapeToIndex(shape) + void SetSubShape(const TopoDS_Shape& subShape); /*! - * \brief Check if inFaceNode argument is necessary for call GetNodeUV(F,..) - * \param F - the face - * \retval bool - return true if the face is periodic - * - * if F is Null, answer about subshape set through IsQuadraticSubMesh() or - * SetSubShape() + * \brief Return ID of the shape set by IsQuadraticSubMesh() or SetSubShape() + * \retval int - shape index in SMESHDS */ - bool GetNodeUVneedInFaceNode(const TopoDS_Face& F = TopoDS_Face()) const; - + int GetSubShapeID() const { return myShapeID; } /*! - * \brief Return U on edge - * \param F - the edge - * \param n - the node - * \retval double - resulting U - * - * Auxilary function called from GetMediumNode() + * \brief Return the shape set by IsQuadraticSubMesh() or SetSubShape() */ - double GetNodeU(const TopoDS_Edge& E, - const SMDS_MeshNode* n); - + TopoDS_Shape GetSubShape() const { return myShape; } - /** - * Special function for search or creation medium node + /*! + * Creates a node */ - const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1, - const SMDS_MeshNode* n2, - const bool force3d); - - /** - * Special function for creation quadratic edge + SMDS_MeshNode* AddNode(double x, double y, double z, int ID = 0); + /*! + * Creates quadratic or linear edge */ - SMDS_QuadraticEdge* AddQuadraticEdge(const SMDS_MeshNode* n1, - const SMDS_MeshNode* n2, - const int id = 0, - const bool force3d = true); - - /** - * Special function for creation quadratic triangle + SMDS_MeshEdge* AddEdge(const SMDS_MeshNode* n1, + const SMDS_MeshNode* n2, + const int id = 0, + const bool force3d = true); + /*! + * Creates quadratic or linear triangle */ SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2, const SMDS_MeshNode* n3, const int id=0, const bool force3d = false); - - /** - * Special function for creation quadratic quadrangle + /*! + * Creates quadratic or linear quadrangle */ SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2, @@ -215,9 +177,8 @@ public: const SMDS_MeshNode* n4, const int id = 0, const bool force3d = false); - - /** - * Special function for creation quadratic tetraahedron + /*! + * Creates quadratic or linear tetraahedron */ SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2, @@ -225,10 +186,8 @@ public: const SMDS_MeshNode* n4, const int id = 0, const bool force3d = true); - - - /** - * Special function for creation quadratic pyramid + /*! + * Creates quadratic or linear pyramid */ SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2, @@ -237,9 +196,8 @@ public: const SMDS_MeshNode* n5, const int id = 0, const bool force3d = true); - - /** - * Special function for creation quadratic pentahedron + /*! + * Creates quadratic or linear pentahedron */ SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2, @@ -249,9 +207,8 @@ public: const SMDS_MeshNode* n6, const int id = 0, const bool force3d = true); - - /** - * Special function for creation quadratic hexahedron + /*! + * Creates quadratic or linear hexahedron */ SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2, @@ -263,45 +220,26 @@ public: const SMDS_MeshNode* n8, const int id = 0, bool force3d = true); - - /*! - * \brief Set order of elements to create - * \param theBuildQuadratic - to build quadratic or not - * - * To be used for quadratic elements creation without preceding - * IsQuadraticSubMesh() or AddQuadraticEdge() call - */ - void SetKeyIsQuadratic(const bool theBuildQuadratic) - { myCreateQuadratic = theBuildQuadratic; } - - /*! - * \brief Return myCreateQuadratic flag - * \retval bool - myCreateQuadratic value - */ - bool GetIsQuadratic() const { return myCreateQuadratic; } - - /*! - * \brief Set shape to make elements on - * \param subShape, subShapeID - shape or its ID (==SMESHDS_Mesh::ShapeToIndex(shape)) + * \brief Return U of the given node on the edge */ - void SetSubShape(const int subShapeID); - void SetSubShape(const TopoDS_Shape& subShape); - + double GetNodeU(const TopoDS_Edge& theEdge, + const SMDS_MeshNode* theNode); /*! - * \brief Return shape or its ID, on which created elements are added - * \retval int - shape index in SMESHDS - * - * Shape is set by calling either IsQuadraticSubMesh() or SetSubShape() + * \brief Return node UV on face + * \param inFaceNode - a node of element being created located inside a face */ - int GetSubShapeID() const { return myShapeID; } + gp_XY GetNodeUV(const TopoDS_Face& F, + const SMDS_MeshNode* n, + const SMDS_MeshNode* inFaceNode=0) const; /*! - * \brief Return shape or its ID, on which created elements are added - * \retval TopoDS_Shape - shape + * \brief Check if inFaceNode argument is necessary for call GetNodeUV(F,..) + * \retval bool - return true if the face is periodic * - * Shape is set by calling either IsQuadraticSubMesh() or SetSubShape() + * if F is Null, answer about subshape set through IsQuadraticSubMesh() or + * SetSubShape() */ - TopoDS_Shape GetSubShape() const { return myShape; } + bool GetNodeUVneedInFaceNode(const TopoDS_Face& F = TopoDS_Face()) const; /*! * \brief Check if shape is a seam edge or it's vertex @@ -321,21 +259,42 @@ public: */ bool IsSeamShape(const TopoDS_Shape& subShape) const { return IsSeamShape( GetMeshDS()->ShapeToIndex( subShape )); } - /*! * \brief Check if the shape set through IsQuadraticSubMesh() or SetSubShape() * has a seam edge * \retval bool - true if it has */ bool HasSeam() const { return !mySeamShapeIds.empty(); } - /*! * \brief Return index of periodic parametric direction of a closed face * \retval int - 1 for U, 2 for V direction */ int GetPeriodicIndex() const { return myParIndex; } - protected: + /** + * Special function for search or creation medium node + */ + const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1, + const SMDS_MeshNode* n2, + const bool force3d); + /*! + * Auxilary function for filling myNLinkNodeMap + */ + void AddNLinkNode(const SMDS_MeshNode* n1, + const SMDS_MeshNode* n2, + const SMDS_MeshNode* n12); + /** + * Auxilary function for filling myNLinkNodeMap + */ + void AddNLinkNodeMap(const NLinkNodeMap& aMap) + { myNLinkNodeMap.insert(aMap.begin(), aMap.end()); } + + /** + * Returns myNLinkNodeMap + */ + const NLinkNodeMap& GetNLinkNodeMap() const { return myNLinkNodeMap; } + +protected: /*! * \brief Select UV on either of 2 pcurves of a seam edge, closest to the given UV @@ -347,20 +306,23 @@ public: private: - void* myMesh; - - int myShapeID; - - // Key for creation quadratic faces - bool myCreateQuadratic; + // Forbiden copy constructor + SMESH_MesherHelper (const SMESH_MesherHelper& theOther) {}; // special map for using during creation quadratic faces - NLinkNodeMap myNLinkNodeMap; + NLinkNodeMap myNLinkNodeMap; std::set< int > mySeamShapeIds; double myPar1, myPar2; // bounds of a closed periodic surface int myParIndex; // bounds' index (1-U, 2-V) + TopoDS_Shape myShape; + SMESH_Mesh* myMesh; + int myShapeID; + + // to create quadratic elements + bool myCreateQuadratic; + bool mySetElemOnShape; };