-// SMESH SMESH : implementaion of SMESH idl descriptions
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// SMESH SMESH : implementaion of SMESH idl descriptions
// File : StdMeshers_Quadrangle_2D.cxx
// Moved here from SMESH_Quadrangle_2D.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
-
+//
#include "StdMeshers_Quadrangle_2D.hxx"
#include "StdMeshers_FaceSide.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMDS_FacePosition.hxx"
-#include <BRepTools.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Surface.hxx>
#include <TColStd_SequenceOfReal.hxx>
#include <TColgp_SequenceOfXY.hxx>
#include <TopExp.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopoDS.hxx>
#include "utilities.h"
_name = "Quadrangle_2D";
_shapeType = (1 << TopAbs_FACE);
_compatibleHypothesis.push_back("QuadranglePreference");
+ _compatibleHypothesis.push_back("TrianglePreference");
myTool = 0;
}
bool isOk = true;
aStatus = SMESH_Hypothesis::HYP_OK;
- // there is only one compatible Hypothesis so far
- const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape, false);
- myQuadranglePreference = hyps.size() > 0;
+ const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape, false);
+ const SMESHDS_Hypothesis *theHyp = 0;
+
+ if(hyps.size() > 0){
+ theHyp = *hyps.begin();
+ if(strcmp("QuadranglePreference", theHyp->GetName()) == 0) {
+ myQuadranglePreference= true;
+ myTrianglePreference= false;
+ }
+ else if(strcmp("TrianglePreference", theHyp->GetName()) == 0){
+ myQuadranglePreference= false;
+ myTrianglePreference= true;
+ }
+ }
+ else {
+ myQuadranglePreference = false;
+ myTrianglePreference = false;
+ }
return isOk;
}
else
d = quad->uv_grid[nbhoriz + near - 1].node;
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
- SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
- meshDS->SetMeshElementOnShape(face, geomFaceID);
+
+ if(!myTrianglePreference){
+ SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
+ meshDS->SetMeshElementOnShape(face, geomFaceID);
+ }
+ else {
+ SplitQuad(meshDS, geomFaceID, a, b, c, d);
+ }
// if node d is not at position g - make additional triangles
if (near - 1 > g) {
else
d = quad->uv_grid[nbhoriz*(nbvertic - 2) + near + 1].node;
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
- SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
- meshDS->SetMeshElementOnShape(face, geomFaceID);
+ if(!myTrianglePreference){
+ SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
+ meshDS->SetMeshElementOnShape(face, geomFaceID);
+ }
+ else {
+ SplitQuad(meshDS, geomFaceID, a, b, c, d);
+ }
if (near + 1 < g) { // if d not is at g - make additional triangles
for (int k = near + 1; k < g; k++) {
else
d = quad->uv_grid[nbhoriz*near - 2].node;
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
- SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
- meshDS->SetMeshElementOnShape(face, geomFaceID);
+
+ if(!myTrianglePreference){
+ SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
+ meshDS->SetMeshElementOnShape(face, geomFaceID);
+ }
+ else {
+ SplitQuad(meshDS, geomFaceID, a, b, c, d);
+ }
if (near - 1 > g) { // if d not is at g - make additional triangles
for (int k = near - 1; k > g; k--) {
else
d = quad->uv_grid[nbhoriz*(near + 1) + 1].node;
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
- SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
- meshDS->SetMeshElementOnShape(face, geomFaceID);
+ if(!myTrianglePreference){
+ SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
+ meshDS->SetMeshElementOnShape(face, geomFaceID);
+ }
+ else {
+ SplitQuad(meshDS, geomFaceID, a, b, c, d);
+ }
if (near + 1 < g) { // if d not is at g - make additional triangles
for (int k = near + 1; k < g; k++) {
return isOk;
}
+//================================================================================
+/*!
+ * \brief Return true if only two given edges meat at their common vertex
+ */
+//================================================================================
+
+static bool twoEdgesMeatAtVertex(const TopoDS_Edge& e1,
+ const TopoDS_Edge& e2,
+ SMESH_Mesh & mesh)
+{
+ TopoDS_Vertex v;
+ if ( !TopExp::CommonVertex( e1, e2, v ))
+ return false;
+ TopTools_ListIteratorOfListOfShape ancestIt( mesh.GetAncestors( v ));
+ for ( ; ancestIt.More() ; ancestIt.Next() )
+ if ( ancestIt.Value().ShapeType() == TopAbs_EDGE )
+ if ( !e1.IsSame( ancestIt.Value() ) && !e2.IsSame( ancestIt.Value() ))
+ return false;
+ return true;
+}
+
//=============================================================================
/*!
*
nbSides<TOP_SIDE, ignoreMediumNodes));
++nbSides;
}
+ // issue 20222. Try to unite only edges shared by two same faces
+ if (nbSides < 4) {
+ // delete found sides
+ { FaceQuadStruct cleaner( *quad ); }
+ quad->side.clear();
+ quad->side.reserve(nbEdgesInWire.front());
+ nbSides = 0;
+
+ SMESH_Block::GetOrderedEdges (F, V, edges, nbEdgesInWire);
+ while ( !edges.empty()) {
+ sideEdges.clear();
+ sideEdges.splice( sideEdges.end(), edges, edges.begin());
+ bool sameSide = true;
+ while ( !edges.empty() && sameSide ) {
+ sameSide =
+ SMESH_Algo::IsContinuous( sideEdges.back(), edges.front() ) &&
+ twoEdgesMeatAtVertex( sideEdges.back(), edges.front(), aMesh );
+ if ( sameSide )
+ sideEdges.splice( sideEdges.end(), edges, edges.begin());
+ }
+ if ( nbSides == 0 ) { // go backward from the first edge
+ sameSide = true;
+ while ( !edges.empty() && sameSide ) {
+ sameSide =
+ SMESH_Algo::IsContinuous( sideEdges.front(), edges.back() ) &&
+ twoEdgesMeatAtVertex( sideEdges.front(), edges.back(), aMesh );
+ if ( sameSide )
+ sideEdges.splice( sideEdges.begin(), edges, --edges.end());
+ }
+ }
+ quad->side.push_back( new StdMeshers_FaceSide(F, sideEdges, &aMesh,
+ nbSides<TOP_SIDE, ignoreMediumNodes));
+ ++nbSides;
+ }
+ }
}
if (nbSides != 4) {
#ifdef _DEBUG_
return uv;
}
-
//=======================================================================
//function : CalcUV2
//purpose : auxilary function for ComputeQuadPref
return uv;
}
+
//=======================================================================
/*!
* Create only quandrangle faces
return isOk;
}
+//=============================================================================
+/*! Split quadrangle in to 2 triangles by smallest diagonal
+ *
+ */
+//=============================================================================
+void StdMeshers_Quadrangle_2D::SplitQuad(SMESHDS_Mesh *theMeshDS,
+ int theFaceID,
+ const SMDS_MeshNode* theNode1,
+ const SMDS_MeshNode* theNode2,
+ const SMDS_MeshNode* theNode3,
+ const SMDS_MeshNode* theNode4)
+{
+ gp_Pnt a(theNode1->X(),theNode1->Y(),theNode1->Z());
+ gp_Pnt b(theNode2->X(),theNode2->Y(),theNode2->Z());
+ gp_Pnt c(theNode3->X(),theNode3->Y(),theNode3->Z());
+ gp_Pnt d(theNode4->X(),theNode4->Y(),theNode4->Z());
+ SMDS_MeshFace* face;
+ if(a.Distance(c) > b.Distance(d)){
+ face = myTool->AddFace(theNode2, theNode4, theNode1);
+ theMeshDS->SetMeshElementOnShape(face, theFaceID );
+ face = myTool->AddFace(theNode2, theNode3, theNode4);
+ theMeshDS->SetMeshElementOnShape(face, theFaceID );
+
+ }
+ else{
+ face = myTool->AddFace(theNode1, theNode2 ,theNode3);
+ theMeshDS->SetMeshElementOnShape(face, theFaceID );
+ face = myTool->AddFace(theNode1, theNode3, theNode4);
+ theMeshDS->SetMeshElementOnShape(face, theFaceID );
+ }
+}