#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"
#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 )
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 ):
_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
// --------------------------------------------------------------
ASSERT( _computeVertexOK );
bool ok = true;
- const std::vector <HEXA_NS::Shape*> 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;
gp_Pnt myCurve_pt_end (LAST_NODE->X(), LAST_NODE->Y(), LAST_NODE->Z());
_buildMyCurve(
- associations,
myCurve_pt_start,
myCurve_pt_end,
myCurve_list,
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 -> "<<nbNodes);
for (int i = 0; i < nbNodes; ++i){
u = _Xx(i, law, nbNodes); //u between [0,1]
return false;
}
- const std::vector <HEXA_NS::Shape*> 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<SMDS_MeshNode*, gp_Pnt> interpolatedPoints;
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];
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 <HEXA_NS::Shape*>& associations, //IN
const gp_Pnt& myCurve_pt_start, //IN
const gp_Pnt& myCurve_pt_end, //IN
std::list< BRepAdaptor_Curve* >& myCurve_list, //INOUT
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
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
GCPnts_AbscissaPoint discret;
if (MYDEBUG){
- MESSAGE("looking for curve: c = "<<myCurve_u);
+ MESSAGE("looking for curve = "<<(long) curve);
+ MESSAGE("looking for curve: curve_u = "<<myCurve_u);
MESSAGE("looking for curve: curve_start = "<<curve_start);
MESSAGE("looking for curve: curve_end = "<<curve_end);
MESSAGE("looking for curve: curve_lenght = "<<myCurve_lengths[curve]);
// compute point
if ( myCurve_ways[curve] ){
-// curve_u = myCurve_firsts[curve] + (myCurve_u - curve_start);
-// discret = GCPnts_AbscissaPoint( *curve, (myCurve_u - curve_start), curve->FirstParameter() );
discret = GCPnts_AbscissaPoint( *curve, (myCurve_u - curve_start), myCurve_starts[curve] );
} else {
-// discret = GCPnts_AbscissaPoint( *curve, myCurve_lengths[curve]- (myCurve_u - curve_start), curve->FirstParameter() );
discret = GCPnts_AbscissaPoint( *curve, myCurve_lengths[curve]- (myCurve_u - curve_start), myCurve_starts[curve] );
}
+ // PutData (discret);
ASSERT(discret.IsDone());
curve_u = discret.Parameter();
ptOnMyCurve = curve->Value( curve_u );
-
-
-
void SMESH_HexaBlocks::_nodeInterpolationUV(double u, double v,
SMDS_MeshNode* Pg, SMDS_MeshNode* Pd, SMDS_MeshNode* Ph, SMDS_MeshNode* Pb,
SMDS_MeshNode* S1, SMDS_MeshNode* S2, SMDS_MeshNode* S3, SMDS_MeshNode* S4,
}
}
-
-TopoDS_Shape SMESH_HexaBlocks::_getShapeOrCompound( const std::vector<HEXA_NS::Shape*>& shapesIn)
+// =========================================================== getFaceShapes
+TopoDS_Shape SMESH_HexaBlocks::getFaceShapes (Hex::Quad& quad)
{
- ASSERT( shapesIn.size()!=0 );
-
- if (shapesIn.size() == 1) {
- HEXA_NS::Shape* assoc = shapesIn.front();
- string strBrep = assoc->getBrep();
- return string2shape( strBrep );
- } else {
- TopoDS_Compound aCompound;
- BRep_Builder aBuilder;
- aBuilder.MakeCompound( aCompound );
-
- for ( std::vector <HEXA_NS::Shape*> ::const_iterator assoc = shapesIn.begin();
- assoc != shapesIn.end();
- ++assoc ){
- string strBrep = (*assoc)->getBrep();
- TopoDS_Shape shape = string2shape( strBrep );
- aBuilder.Add( aCompound, shape );
- }
- return aCompound;
- }
+ int nbass = quad.countAssociation ();
+ Hex::FaceShape* face = quad.getAssociation (0);
+ if (nbass==1)
+ return face->getShape ();
+
+ TopoDS_Compound compound;
+ BRep_Builder builder;
+ builder.MakeCompound (compound);
+
+ for (int nro=0 ; nro < nbass ; nro++)
+ {
+ face = quad.getAssociation (nro);
+ TopoDS_Shape shape = face->getShape ();
+ builder.Add (compound, shape);
+ }
+
+ return compound;
}
if(MYDEBUG) MESSAGE("_fillGroup() : end >>>>>>>>");
}
-
-
-
-
-
-// not used, for backup purpose only:
-void SMESH_HexaBlocks::_getCurve( const std::vector<HEXA_NS::Shape*>& shapesIn,
- Handle_Geom_Curve& curveOut, double& curveFirstOut, double& curveLastOut )
-{
-// std::cout<<"------------------- _getCurve ------------ "<<std::endl;
- GeomConvert_CompCurveToBSplineCurve* gen = NULL;
-
- double curvesLenght = 0.;
- double curvesFirst = shapesIn.front()->getStart();
- double curvesLast = shapesIn.back()->getEnd();
-
- for ( std::vector <HEXA_NS::Shape*> ::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 -> "<<curvesFirst<<std::endl;
- std::cout<<"curvesLast -> "<<curvesLast<<std::endl;
- std::cout<<"curvesLenght -> "<<curvesLenght<<std::endl;
- std::cout<<"curveFirstOut -> "<<curveFirstOut<<std::endl;
- std::cout<<"curveLastOut -> "<<curveLastOut<<std::endl;
-
-}
-
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : SMESH_HexaBlocks.hxx
-// Author :
+// Author :
// Module : SMESH
//
#ifndef _SMESH_HexaBlocks_HeaderFile
#include "SMESH_Mesh.hxx"
#include "SMESH_Group.hxx"
#include "hexa_base.hxx" // from HexaBlocks
+#include "HexFaceShape.hxx" // from HexaBlocks
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
// 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
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);
double _edgeLength(const TopoDS_Edge & E);
void _buildMyCurve(
- const std::vector <HEXA_NS::Shape*>& associations, //IN
const gp_Pnt& myCurve_start, //IN
const gp_Pnt& myCurve_end, //IN
std::list< BRepAdaptor_Curve* >& myCurve, //INOUT
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
SMDS_MeshNode* S0, SMDS_MeshNode* S1, SMDS_MeshNode* S2, SMDS_MeshNode* S3,
double& xOut, double& yOut, double& zOut );
- TopoDS_Shape _getShapeOrCompound( const std::vector<HEXA_NS::Shape*>& shapesIn );
+ // TopoDS_Shape _getShapeOrCompound( const std::vector<HEXA_NS::Shape*>& shapesIn );
+ TopoDS_Shape getFaceShapes (Hex::Quad& quad);
gp_Pnt _intersect( const gp_Pnt& Pt,
const gp_Vec& u, const gp_Vec& v,
int _total;
int _found;
int _notFound;
-
- // not used, for backup purpose only:
- void _getCurve( const std::vector<HEXA_NS::Shape*>& shapesIn,
- Handle_Geom_Curve& curveOut, double& curveFirstOut, double& curveLastOut );
-// bool computeEdgeByAssoc2( HEXA_NS::Edge& edge, HEXA_NS::Law& law); // alternative method
};