From: abuhsing Date: Wed, 12 Dec 2012 15:22:06 +0000 (+0000) Subject: Abu : Modifs du plugin Hexa du 12/12/12 X-Git-Tag: V6_main_FINAL~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b96a1ca8017178840b3ee5043795ad1038b22937;p=plugins%2Fhexablockplugin.git Abu : Modifs du plugin Hexa du 12/12/12 ---------------------------------------------------------------------- Committing in . Modified Files: Tag: V6_main src/HEXABLOCKPlugin/HEXABLOCKPlugin_mesh.cxx src/HEXABLOCKPlugin/HEXABLOCKPlugin_mesh.hxx ---------------------------------------------------------------------- --- diff --git a/src/HEXABLOCKPlugin/HEXABLOCKPlugin_mesh.cxx b/src/HEXABLOCKPlugin/HEXABLOCKPlugin_mesh.cxx index b513a0b..3d95e96 100755 --- a/src/HEXABLOCKPlugin/HEXABLOCKPlugin_mesh.cxx +++ b/src/HEXABLOCKPlugin/HEXABLOCKPlugin_mesh.cxx @@ -61,8 +61,9 @@ #include "HexQuad.hxx" #include "HexHexa.hxx" #include "HexPropagation.hxx" -#include "HexShape.hxx" #include "HexGroup.hxx" +#include "hexa_base.hxx" +#include "HexAssoEdge.hxx" // HEXABLOCKPLUGIN includes #include "HEXABLOCKPlugin_mesh.hxx" @@ -89,15 +90,14 @@ #endif #ifdef _DEBUG_ -static int MYDEBUG = HEXA_NS::on_debug (); +static int MYDEBUG = HEXA_NS::on_debug (); #else -static int MYDEBUG = 0; +static int MYDEBUG = 0; #endif static double HEXA_EPS = 1.0e-3; //1E-3; static double HEXA_QUAD_WAY = PI/4.; //3.*PI/8.; -// static double HEXA_QUAD_WAY2 = 499999999.*PI/1000000000.; // ============================================================ string2shape TopoDS_Shape string2shape( const string& brep ) @@ -137,35 +137,22 @@ double edge_length(const TopoDS_Edge & E) return length; } // =============================================================== make_curve -BRepAdaptor_Curve* make_curve (Hex::Shape* assoc, gp_Pnt& pstart, gp_Pnt& pend, - double& length, double& u_start) +BRepAdaptor_Curve* make_curve (gp_Pnt& pstart, gp_Pnt& pend, + double& length, double& u_start, + HEXA_NS::Edge& edge, int nro) { - string theBrep = assoc->getBrep(); - double ass_debut = std::min (assoc->getStart(), assoc->getEnd()); - double ass_fin = std::max (assoc->getStart(), assoc->getEnd()); - TopoDS_Shape theShape = string2shape( theBrep ); - TopoDS_Edge theEdge = TopoDS::Edge( theShape ); - - double curv_length = edge_length( theEdge ); - double u_end = 0; - - if ( curv_length <= 0.0 ) - return NULL; - - BRepAdaptor_Curve* theCurve = new BRepAdaptor_Curve( theEdge ); - - GCPnts_AbscissaPoint discret_start (*theCurve, curv_length*ass_debut, - theCurve->FirstParameter() ); - GCPnts_AbscissaPoint discret_end (*theCurve, curv_length*ass_fin, - theCurve->FirstParameter() ); - u_start = discret_start.Parameter(); - u_end = discret_end .Parameter(); - - ASSERT( discret_start.IsDone() && discret_end.IsDone() ); - pstart = theCurve->Value( u_start); - pend = theCurve->Value( u_end ); - length = curv_length*( ass_fin - ass_debut); - return theCurve; + Hex::AssoEdge* asso = edge.getAssociation (nro); + BRepAdaptor_Curve* the_curve = asso->getCurve(); + length = asso->length (); + if (length <= 1e-6) + return NULL; + + const double* point1 = asso->getOrigin (); + const double* point2 = asso->getExtrem (); + pstart = gp_Pnt (point1[0], point1[1], point1[2]); + pend = gp_Pnt (point2[0], point2[1], point2[2]); + u_start = asso->getUstart(); + return the_curve; } // ============================================================== Constructeur // SMESH_HexaBlocks::SMESH_HexaBlocks( SMESH_Mesh* theMesh ): @@ -206,86 +193,7 @@ bool SMESH_HexaBlocks::computeVertex(HEXA_NS::Vertex& vx) _node [&vx] = new_node; //needed in computeEdge() _computeVertexOK = true; return true; - -/*********************************** - bool ok = computeVertexByAssoc( vx ); - if ( ok == false ){ - ok = computeVertexByModel( vx ); - } - if (ok == true){ - _computeVertexOK = true; - } - return ok; -***********************************/ -} - - -bool SMESH_HexaBlocks::computeVertexByAssoc(HEXA_NS::Vertex& vx) -{ - if(MYDEBUG) MESSAGE("computeVertexByAssoc() : : begin <<<<<<"); - bool ok = true; - - SMDS_MeshNode* newNode = NULL; // new node on mesh - double x, y, z; //new node coordinates - - HEXA_NS::Shape* assoc = vx.getAssociation(); - if ( assoc == NULL ){ - if (MYDEBUG){ - MESSAGE("computeVertexByAssoc() : ASSOC not found " << vx.getName ()); - // vx.printName(); - } - return false; - } - - string strBrep = assoc->getBrep(); - TopoDS_Shape shape = string2shape( strBrep ); - ok = shape2coord( shape, x, y, z ); -// ASSERT(ok); - if (!ok) throw (SALOME_Exception(LOCALIZED("vertex association : shape2coord() error "))); - newNode = _theMeshDS->AddNode(x, y, z); - if (_node.count(&vx) >= 1 and MYDEBUG) MESSAGE("_node : ALREADY"); - _node[&vx] = newNode;//needed in computeEdge() - _vertex[newNode] = &vx; - - if (MYDEBUG){ - MESSAGE("computeVertexByAssoc() : ASSOC found " << vx.getName()); - /// vx.printName(); - MESSAGE("( "<< x <<","<< y <<","<< z <<" )"); - } - - if(MYDEBUG) MESSAGE("computeVertexByAssoc() : end >>>>>>>>"); - return ok; -} - -bool SMESH_HexaBlocks::computeVertexByModel(HEXA_NS::Vertex& vx) -{ - if(MYDEBUG) MESSAGE("computeVertexByModel() : : begin <<<<<<"); - bool ok = true; - - SMDS_MeshNode* newNode = NULL; // new node on mesh - double x, y, z; //new node coordinates - -// vx.printName(); -// std::cout << std::endl; - x = vx.getX(); - y = vx.getY(); - z = vx.getZ(); - - newNode = _theMeshDS->AddNode(x, y, z); - - if (_node.count(&vx) >= 1 and MYDEBUG) MESSAGE("_node : ALREADY"); - _node[&vx] = newNode;//needed in computeEdge() - _vertex[newNode] = &vx; - if (MYDEBUG){ - MESSAGE("computeVertexByModel() :" << vx.getName()); - /// vx.printName(); - MESSAGE("( "<< x <<","<< y <<","<< z <<" )"); - } - - if(MYDEBUG) MESSAGE("computeVertexByModel() : end >>>>>>>>"); - return ok; } - // -------------------------------------------------------------- // Edge computing // -------------------------------------------------------------- @@ -320,10 +228,9 @@ bool SMESH_HexaBlocks::computeEdgeByAssoc( HEXA_NS::Edge& edge, HEXA_NS::Law& la ASSERT( _computeVertexOK ); bool ok = true; - const std::vector associations = edge.getAssociations(); - if ( associations.size() == 0 ){ - return false; - } + if (NOT edge.isAssociated()) + return false; + //vertex from edge HEXA_NS::Vertex* vx0 = NULL; HEXA_NS::Vertex* vx1 = NULL; @@ -352,7 +259,6 @@ bool SMESH_HexaBlocks::computeEdgeByAssoc( HEXA_NS::Edge& edge, HEXA_NS::Law& la gp_Pnt myCurve_pt_end (LAST_NODE->X(), LAST_NODE->Y(), LAST_NODE->Z()); _buildMyCurve( - associations, myCurve_pt_start, myCurve_pt_end, myCurve_list, @@ -381,6 +287,11 @@ bool SMESH_HexaBlocks::computeEdgeByAssoc( HEXA_NS::Edge& edge, HEXA_NS::Law& la double u, myCurve_u; double myCurve_start_u = 0.; int nbNodes = law.getNodes(); //law of discretization + if (myCurve_list.size()==0) + { + PutData (edge.getName()); + nbNodes = 0; + } if (MYDEBUG) MESSAGE("nbNodes -> "< shapes = quad.getAssociations(); - if ( shapes.size() == 0 ){ - if(MYDEBUG) MESSAGE("computeQuadByAssoc() : end >>>>>>>>"); - return false; - } - TopoDS_Shape shapeOrCompound = _getShapeOrCompound( shapes ); -// bool quadWay = _computeQuadWay( quad, S1, S2, S3, S4, &shapeOrCompound ); -// bool quadWay = _computeQuadWay( quad ); + int nbass = quad.countAssociation (); + if (nbass==0) + { + if(MYDEBUG) MESSAGE("computeQuadByAssoc() : end >>>>>>>>"); + return false; + } + + TopoDS_Shape shapeOrCompound = getFaceShapes ( quad ); std::map interpolatedPoints; @@ -829,7 +740,6 @@ bool SMESH_HexaBlocks::computeQuadByAssoc( HEXA_NS::Quad& quad, bool way ) int jSize = nodesOnQuad[0].size(); S1 = nodesOnQuad[0][0]; -// S2 = nodesOnQuad[bNodes.size()-1][0]; S2 = nodesOnQuad[iSize-1][0]; S4 = nodesOnQuad[0][jSize-1]; S3 = nodesOnQuad[iSize-1][jSize-1]; @@ -1298,11 +1208,10 @@ double SMESH_HexaBlocks::_edgeLength(const TopoDS_Edge & E) if(MYDEBUG) MESSAGE("_edgeLength() : end >>>>>>>>"); return length; } - +//--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 // ============================================================== _buildMyCurve // === construire ma courbe a moi void SMESH_HexaBlocks::_buildMyCurve( - const std::vector & associations, //IN const gp_Pnt& myCurve_pt_start, //IN const gp_Pnt& myCurve_pt_end, //IN std::list< BRepAdaptor_Curve* >& myCurve_list, //INOUT @@ -1323,15 +1232,14 @@ void SMESH_HexaBlocks::_buildMyCurve( double u_start = 0; double curv_length = 0; - int nbass = associations.size (); + int nbass = edge.countAssociation(); for (int nro = 0 ; nro < nbass ; ++nro) { - theCurve = make_curve (associations[nro], curv_start, curv_end, - curv_length, u_start); + theCurve = make_curve (curv_start, curv_end, curv_length, u_start, + edge, nro); if (theCurve != NULL) { bool sens = true; - double f, l; if ( thePreviousCurve == NULL ) { // setting current_way and first curve way @@ -1394,10 +1302,9 @@ void SMESH_HexaBlocks::_buildMyCurve( myCurve_lengths[theCurve] = curv_length; myCurve_tot_len += curv_length; - thePreviousCurve = theCurve; + thePreviousCurve = theCurve; p_curv_start = curv_start; p_curv_end = curv_end; - }//if ( theCurveLength > 0 ) }// for @@ -1438,7 +1345,8 @@ gp_Pnt SMESH_HexaBlocks::_getPtOnMyCurve( GCPnts_AbscissaPoint discret; if (MYDEBUG){ - MESSAGE("looking for curve: c = "<>>>>>>>"); } - - - - - -// not used, for backup purpose only: -void SMESH_HexaBlocks::_getCurve( const std::vector& shapesIn, - Handle_Geom_Curve& curveOut, double& curveFirstOut, double& curveLastOut ) -{ -// std::cout<<"------------------- _getCurve ------------ "<getStart(); - double curvesLast = shapesIn.back()->getEnd(); - - for ( std::vector ::const_iterator assoc = shapesIn.begin(); - assoc != shapesIn.end(); - ++assoc ){ - string strBrep = (*assoc)->getBrep(); - TopoDS_Shape shape = string2shape( strBrep ); - TopoDS_Edge Edge = TopoDS::Edge(shape); - double f, l; - Handle(Geom_Curve) curve = BRep_Tool::Curve(Edge, f, l); - curvesLenght += l-f; - Handle(Geom_BoundedCurve) bCurve = Handle(Geom_BoundedCurve)::DownCast(curve); - if ( gen == NULL ){ - gen = new GeomConvert_CompCurveToBSplineCurve(bCurve); - } else { - bool bb=gen->Add(bCurve, Precision::Confusion(), Standard_True, Standard_False, 1); - ASSERT(bb); - } - } - curveFirstOut = curvesFirst/curvesLenght; - curveLastOut = curvesLenght - (1.-curvesLast)/curvesLenght; - curveOut = gen->BSplineCurve(); - - std::cout<<"curvesFirst -> "< "< "< "< "< @@ -78,11 +79,6 @@ public: // Vertex computing // -------------------------------------------------------------- bool computeVertex( HEXA_NS::Vertex& vertex ); - // Association solving - bool computeVertexByAssoc( HEXA_NS::Vertex& vertex ); - // Automatic solving - bool computeVertexByModel( HEXA_NS::Vertex& vertex ); - // -------------------------------------------------------------- // Edge computing @@ -90,7 +86,7 @@ public: bool computeEdge( HEXA_NS::Edge& edge, HEXA_NS::Law& law); // Association solving bool computeEdgeByAssoc( HEXA_NS::Edge& edge, HEXA_NS::Law& law); - + // Automatic solving bool computeEdgeByShortestWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law); bool computeEdgeByPlanWire( HEXA_NS::Edge& edge, HEXA_NS::Law& law); @@ -133,7 +129,6 @@ private: double _edgeLength(const TopoDS_Edge & E); void _buildMyCurve( - const std::vector & associations, //IN const gp_Pnt& myCurve_start, //IN const gp_Pnt& myCurve_end, //IN std::list< BRepAdaptor_Curve* >& myCurve, //INOUT @@ -143,7 +138,7 @@ private: std::map< BRepAdaptor_Curve*, double>& myCurve_starts, //INOUT HEXA_NS::Edge& edge); // For diagnostic - gp_Pnt _getPtOnMyCurve( + gp_Pnt _getPtOnMyCurve( const double& myCurve_u, //IN std::map< BRepAdaptor_Curve*, bool>& myCurve_ways, //IN std::map< BRepAdaptor_Curve*, double>& myCurve_lengths,//IN @@ -157,7 +152,8 @@ private: SMDS_MeshNode* S0, SMDS_MeshNode* S1, SMDS_MeshNode* S2, SMDS_MeshNode* S3, double& xOut, double& yOut, double& zOut ); - TopoDS_Shape _getShapeOrCompound( const std::vector& shapesIn ); + // TopoDS_Shape _getShapeOrCompound( const std::vector& shapesIn ); + TopoDS_Shape getFaceShapes (Hex::Quad& quad); gp_Pnt _intersect( const gp_Pnt& Pt, const gp_Vec& u, const gp_Vec& v, @@ -206,11 +202,6 @@ private: int _total; int _found; int _notFound; - - // not used, for backup purpose only: - void _getCurve( const std::vector& shapesIn, - Handle_Geom_Curve& curveOut, double& curveFirstOut, double& curveLastOut ); -// bool computeEdgeByAssoc2( HEXA_NS::Edge& edge, HEXA_NS::Law& law); // alternative method };