myHelper = &helper;
_quadraticMesh = myHelper->IsQuadraticSubMesh(aShape);
+ myHelper->SetElementsOnShape( true );
myNeedSmooth = false;
myCheckOri = false;
enum { NOT_COMPUTED = -1, COMPUTE_FAILED = 0, COMPUTE_OK = 1 };
int res = NOT_COMPUTED;
- if (myQuadranglePreference)
+ if ( myQuadranglePreference )
{
int nfull = n1+n2+n3+n4;
if ((nfull % 2) == 0 && ((n1 != n3) || (n2 != n4)))
res = computeQuadPref( aMesh, F, quad );
}
}
- else if (myQuadType == QUAD_REDUCED)
+ else if ( myQuadType == QUAD_REDUCED )
{
int n13 = n1 - n3;
int n24 = n2 - n4;
b = quad->uv_grid[ j * nbhoriz + i + 1].node;
c = quad->uv_grid[(j + 1) * nbhoriz + i + 1].node;
d = quad->uv_grid[(j + 1) * nbhoriz + i ].node;
- SMDS_MeshFace* face = myHelper->AddFace(a, b, c, d);
- if (face) {
- meshDS->SetMeshElementOnShape(face, geomFaceID);
- }
+ myHelper->AddFace(a, b, c, d);
}
}
}
if (near == g) { // make triangle
- SMDS_MeshFace* face = myHelper->AddFace(a, b, c);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, b, c);
}
else { // make quadrangle
if (near - 1 < ilow)
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
if (!myTrianglePreference){
- SMDS_MeshFace* face = myHelper->AddFace(a, b, c, d);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, b, c, d);
}
else {
splitQuadFace(meshDS, geomFaceID, a, b, c, d);
d = uv_e3[1].node;
else
d = quad->uv_grid[nbhoriz + k - 1].node;
- SMDS_MeshFace* face = myHelper->AddFace(a, c, d);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, c, d);
}
}
g = near;
d = quad->UVPt( g, nbvertic-2 ).node;
if ( myTrianglePreference )
{
- if ( SMDS_MeshFace* face = myHelper->AddFace(a, d, c))
- meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, d, c);
}
else
{
if ( SMDS_MeshFace* face = myHelper->AddFace(a, b, d, c))
{
- meshDS->SetMeshElementOnShape(face, geomFaceID);
SMESH_ComputeErrorPtr& err = aMesh.GetSubMesh( aFace )->GetComputeError();
if ( !err || err->IsOK() || err->myName < COMPERR_WARNING )
{
}
if (near == g) { // make triangle
- SMDS_MeshFace* face = myHelper->AddFace(a, b, c);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, b, c);
}
else { // make quadrangle
if (near + 1 > iup)
d = quad->uv_grid[nbhoriz*(nbvertic - 2) + near + 1].node;
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
if (!myTrianglePreference){
- SMDS_MeshFace* face = myHelper->AddFace(a, b, c, d);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, b, c, d);
}
else {
splitQuadFace(meshDS, geomFaceID, a, b, c, d);
d = uv_e1[nbright - 2].node;
else
d = quad->uv_grid[nbhoriz*(nbvertic - 2) + k + 1].node;
- SMDS_MeshFace* face = myHelper->AddFace(a, c, d);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, c, d);
}
}
g = near;
}
if (near == g) { // make triangle
- SMDS_MeshFace* face = myHelper->AddFace(a, b, c);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, b, c);
}
else { // make quadrangle
if (near - 1 < jlow)
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
if (!myTrianglePreference){
- SMDS_MeshFace* face = myHelper->AddFace(a, b, c, d);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, b, c, d);
}
else {
splitQuadFace(meshDS, geomFaceID, a, b, c, d);
d = uv_e0[nbdown - 2].node;
else
d = quad->uv_grid[nbhoriz*k - 2].node;
- SMDS_MeshFace* face = myHelper->AddFace(a, c, d);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, c, d);
}
}
g = near;
d = quad->UVPt( 1, g ).node;
if ( myTrianglePreference )
{
- if ( SMDS_MeshFace* face = myHelper->AddFace(a, d, c))
- meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, d, c);
}
else
{
if ( SMDS_MeshFace* face = myHelper->AddFace(a, b, d, c))
{
- meshDS->SetMeshElementOnShape(face, geomFaceID);
SMESH_ComputeErrorPtr& err = aMesh.GetSubMesh( aFace )->GetComputeError();
if ( !err || err->IsOK() || err->myName < COMPERR_WARNING )
{
}
if (near == g) { // make triangle
- SMDS_MeshFace* face = myHelper->AddFace(a, b, c);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, b, c);
}
else { // make quadrangle
if (near + 1 > jup)
else
d = quad->uv_grid[nbhoriz*(near + 1) + 1].node;
if (!myTrianglePreference) {
- SMDS_MeshFace* face = myHelper->AddFace(a, b, c, d);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, b, c, d);
}
else {
splitQuadFace(meshDS, geomFaceID, a, b, c, d);
d = quad->uv_grid[nbhoriz*jup + 1].node; //uv_e2[1].node;
else
d = quad->uv_grid[nbhoriz*(k + 1) + 1].node;
- SMDS_MeshFace* face = myHelper->AddFace(a, c, d);
- if (face) meshDS->SetMeshElementOnShape(face, geomFaceID);
+ myHelper->AddFace(a, c, d);
}
}
g = near;
int nbhoriz = Min( bSide.NbPoints(), tSide.NbPoints() );
int nbvertic = Min( rSide.NbPoints(), lSide.NbPoints() );
+ if ( nbhoriz < 1 || nbvertic < 1 )
+ return error("Algo error: empty quad");
if ( myQuadList.size() == 1 )
{
}
sideLCb = StdMeshers_FaceSide::New( pointsLCb, aFace );
p3dom = pointsLCb.back();
+
+ gp_Pnt xyz = S->Value( p3dom.u, p3dom.v );
+ p3dom.node = myHelper->AddNode( xyz.X(), xyz.Y(), xyz.Z(), 0, p3dom.u, p3dom.v );
+ pointsLCb.back() = p3dom;
}
// Make a side separating domains L and Ct
StdMeshers_FaceSidePtr sideLCt;
sideRCb = StdMeshers_FaceSide::New( pointsRCb, aFace );
pTBL = pointsLCb.back();
pTBR = pointsRCb.back();
+ {
+ gp_Pnt xyz = S->Value( pTBL.u, pTBL.v );
+ pTBL.node = myHelper->AddNode( xyz.X(), xyz.Y(), xyz.Z(), 0, pTBL.u, pTBL.v );
+ pointsLCb.back() = pTBL;
+ }
+ {
+ gp_Pnt xyz = S->Value( pTBR.u, pTBR.v );
+ pTBR.node = myHelper->AddNode( xyz.X(), xyz.Y(), xyz.Z(), 0, pTBR.u, pTBR.v );
+ pointsRCb.back() = pTBR;
+ }
}
// Make sides separating domains Ct and L and R
StdMeshers_FaceSidePtr sideLCt, sideRCt;
for (i=1; i<=dl; i++) {
for (j=1; j<nl; j++) {
if (WisF) {
- SMDS_MeshFace* F =
- myHelper->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
- NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
- if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
+ myHelper->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
+ NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
}
}
}
for (i=1; i<=dr; i++) {
for (j=1; j<nr; j++) {
if (WisF) {
- SMDS_MeshFace* F =
- myHelper->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
- NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
- if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
+ myHelper->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
+ NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
}
}
}
for (i=1; i<nb; i++) {
for (j=1; j<nbv; j++) {
if (WisF) {
- SMDS_MeshFace* F =
- myHelper->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
- NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
- if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
+ myHelper->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
+ NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
}
}
}
for (j=1; j<nnn-1; j++) {
for (i=1; i<nb; i++) {
if (WisF) {
- SMDS_MeshFace* F =
- myHelper->AddFace(NodesBRD.Value(i,j), NodesBRD.Value(i+1,j),
- NodesBRD.Value(i+1,j+1), NodesBRD.Value(i,j+1));
- if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
+ myHelper->AddFace(NodesBRD.Value(i,j), NodesBRD.Value(i+1,j),
+ NodesBRD.Value(i+1,j+1), NodesBRD.Value(i,j+1));
}
}
}
for (j=1; j<=drl+addv; j++) {
for (i=1; i<nb; i++) {
if (WisF) {
- SMDS_MeshFace* F =
- myHelper->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
- NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
- if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
+ myHelper->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
+ NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
}
}
} // end nr<nl
}
for (i=1; i<nt; i++) {
if (WisF) {
- SMDS_MeshFace* F =
- myHelper->AddFace(NodesLast.Value(i,1), NodesLast.Value(i+1,1),
- NodesLast.Value(i+1,2), NodesLast.Value(i,2));
- if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
+ myHelper->AddFace(NodesLast.Value(i,1), NodesLast.Value(i+1,1),
+ NodesLast.Value(i+1,2), NodesLast.Value(i,2));
}
}
} // if ((drl+addv) > 0)
const SMDS_MeshNode* theNode3,
const SMDS_MeshNode* theNode4)
{
- SMDS_MeshFace* face;
if ( SMESH_TNodeXYZ( theNode1 ).SquareDistance( theNode3 ) >
SMESH_TNodeXYZ( theNode2 ).SquareDistance( theNode4 ) )
{
- face = myHelper->AddFace(theNode2, theNode4 , theNode1);
- if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
- face = myHelper->AddFace(theNode2, theNode3, theNode4);
- if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
+ myHelper->AddFace(theNode2, theNode4 , theNode1);
+ myHelper->AddFace(theNode2, theNode3, theNode4);
}
else
{
- face = myHelper->AddFace(theNode1, theNode2 ,theNode3);
- if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
- face = myHelper->AddFace(theNode1, theNode3, theNode4);
- if (face) theMeshDS->SetMeshElementOnShape(face, theFaceID);
+ myHelper->AddFace(theNode1, theNode2 ,theNode3);
+ myHelper->AddFace(theNode1, theNode3, theNode4);
}
}
// create faces
for (i=1; i<=dl; i++) {
for (j=1; j<nl; j++) {
- SMDS_MeshFace* F =
- myHelper->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
- NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
- if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
+ myHelper->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
+ NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
}
}
}
// create faces
for (i=1; i<=dr; i++) {
for (j=1; j<nr; j++) {
- SMDS_MeshFace* F =
- myHelper->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
- NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
- if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
+ myHelper->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
+ NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
}
}
}
// create faces
for (i=1; i<nb; i++) {
for (j=1; j<nbv; j++) {
- SMDS_MeshFace* F =
- myHelper->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
- NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
- if (F) meshDS->SetMeshElementOnShape(F, geomFaceID);
+ myHelper->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
+ NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
}
}
} // end Multiple Reduce implementation
if (uv_eb.size() != nb || uv_er.size() != nr || uv_et.size() != nt || uv_el.size() != nl)
return error(COMPERR_BAD_INPUT_MESH);
- myHelper->SetElementsOnShape( true );
-
gp_UV uv[ UV_SIZE ];
uv[ UV_A0 ].SetCoord( uv_eb.front().u, uv_eb.front().v);
uv[ UV_A1 ].SetCoord( uv_eb.back().u, uv_eb.back().v );
{
if ( !myNeedSmooth ) return;
- // Get nodes to smooth
+ SMESHDS_Mesh* meshDS = myHelper->GetMeshDS();
+ const double tol = BRep_Tool::Tolerance( quad->face );
+ Handle(ShapeAnalysis_Surface) surface = myHelper->GetSurface( quad->face );
+
+ if ( myHelper->HasDegeneratedEdges() && myForcedPnts.empty() )
+ {
+ // "smooth" by computing node positions using 3D TFI and further projection
- // TODO: do not smooth fixed nodes
+ int nbhoriz = quad->iSize;
+ int nbvertic = quad->jSize;
+
+ SMESH_TNodeXYZ a0( quad->UVPt( 0, 0 ).node );
+ SMESH_TNodeXYZ a1( quad->UVPt( nbhoriz-1, 0 ).node );
+ SMESH_TNodeXYZ a2( quad->UVPt( nbhoriz-1, nbvertic-1 ).node );
+ SMESH_TNodeXYZ a3( quad->UVPt( 0, nbvertic-1 ).node );
+
+ for (int i = 1; i < nbhoriz-1; i++)
+ {
+ SMESH_TNodeXYZ p0( quad->UVPt( i, 0 ).node );
+ SMESH_TNodeXYZ p2( quad->UVPt( i, nbvertic-1 ).node );
+ for (int j = 1; j < nbvertic-1; j++)
+ {
+ SMESH_TNodeXYZ p1( quad->UVPt( nbhoriz-1, j ).node );
+ SMESH_TNodeXYZ p3( quad->UVPt( 0, j ).node );
+
+ UVPtStruct& uvp = quad->UVPt( i, j );
+
+ gp_Pnt p = myHelper->calcTFI(uvp.x,uvp.y, a0,a1,a2,a3, p0,p1,p2,p3);
+ gp_Pnt2d uv = surface->NextValueOfUV( uvp.UV(), p, 10*tol );
+ gp_Pnt pnew = surface->Value( uv );
+
+ meshDS->MoveNode( uvp.node, pnew.X(), pnew.Y(), pnew.Z() );
+ uvp.u = uv.X();
+ uvp.v = uv.Y();
+ }
+ }
+ return;
+ }
+
+ // Get nodes to smooth
typedef map< const SMDS_MeshNode*, TSmoothNode, TIDCompare > TNo2SmooNoMap;
TNo2SmooNoMap smooNoMap;
- const TopoDS_Face& geomFace = TopoDS::Face( myHelper->GetSubShape() );
- Handle(Geom_Surface) surface = BRep_Tool::Surface( geomFace );
- double U1, U2, V1, V2;
- surface->Bounds(U1, U2, V1, V2);
- GeomAPI_ProjectPointOnSurf proj;
- proj.Init( surface, U1, U2, V1, V2, BRep_Tool::Tolerance( geomFace ) );
-
- SMESHDS_Mesh* meshDS = myHelper->GetMeshDS();
- SMESHDS_SubMesh* fSubMesh = meshDS->MeshElements( geomFace );
- SMDS_NodeIteratorPtr nIt = fSubMesh->GetNodes();
+ // fixed nodes
+ set< const SMDS_MeshNode* > fixedNodes;
+ for ( size_t i = 0; i < myForcedPnts.size(); ++i )
+ {
+ fixedNodes.insert( myForcedPnts[i].node );
+ if ( myForcedPnts[i].node->getshapeId() != myHelper->GetSubShapeID() )
+ {
+ TSmoothNode & sNode = smooNoMap[ myForcedPnts[i].node ];
+ sNode._uv = myForcedPnts[i].uv;
+ sNode._xyz = SMESH_TNodeXYZ( myForcedPnts[i].node );
+ }
+ }
+ SMESHDS_SubMesh* fSubMesh = meshDS->MeshElements( quad->face );
+ SMDS_NodeIteratorPtr nIt = fSubMesh->GetNodes();
while ( nIt->more() ) // loop on nodes bound to a FACE
{
const SMDS_MeshNode* node = nIt->next();
TSmoothNode & sNode = smooNoMap[ node ];
- sNode._uv = myHelper->GetNodeUV( geomFace, node );
+ sNode._uv = myHelper->GetNodeUV( quad->face, node );
sNode._xyz = SMESH_TNodeXYZ( node );
+ if ( fixedNodes.count( node ))
+ continue; // fixed - no triangles
// set sNode._triangles
SMDS_ElemIteratorPtr fIt = node->GetInverseElementIterator( SMDSAbs_Face );
}
}
// set _uv of smooth nodes on FACE boundary
- for ( unsigned i = 0; i < quad->side.size(); ++i )
- {
- const vector<UVPtStruct>& uvVec = quad->side[i].GetUVPtStruct();
- for ( unsigned j = 0; j < uvVec.size(); ++j )
- {
- TSmoothNode & sNode = smooNoMap[ uvVec[j].node ];
- sNode._uv = uvVec[j].UV();
- sNode._xyz = SMESH_TNodeXYZ( uvVec[j].node );
- }
- }
+ set< StdMeshers_FaceSide* > sidesOnEdge;
+ list< FaceQuadStruct::Ptr >::iterator q = myQuadList.begin();
+ for ( ; q != myQuadList.end() ; ++q )
+ for ( size_t i = 0; i < (*q)->side.size(); ++i )
+ if ( ! (*q)->side[i].grid->Edge(0).IsNull() &&
+ //(*q)->nbNodeOut( i ) == 0 &&
+ sidesOnEdge.insert( (*q)->side[i].grid.get() ).second )
+ {
+ const vector<UVPtStruct>& uvVec = (*q)->side[i].grid->GetUVPtStruct();
+ for ( unsigned j = 0; j < uvVec.size(); ++j )
+ {
+ TSmoothNode & sNode = smooNoMap[ uvVec[j].node ];
+ sNode._uv = uvVec[j].UV();
+ sNode._xyz = SMESH_TNodeXYZ( uvVec[j].node );
+ }
+ }
// define refernce orientation in 2D
TNo2SmooNoMap::iterator n2sn = smooNoMap.begin();
{
// compute a new XYZ
gp_XYZ newXYZ (0,0,0);
- for ( unsigned i = 0; i < sNode._triangles.size(); ++i )
+ for ( size_t i = 0; i < sNode._triangles.size(); ++i )
newXYZ += sNode._triangles[i]._n1->_xyz;
newXYZ /= sNode._triangles.size();
// compute a new UV by projection
- proj.Perform( newXYZ );
- isValid = ( proj.IsDone() && proj.NbPoints() > 0 );
- if ( isValid )
- {
- // check validity of the newUV
- Quantity_Parameter u,v;
- proj.LowerDistanceParameters( u, v );
- newUV.SetCoord( u, v );
- for ( unsigned i = 0; i < sNode._triangles.size() && isValid; ++i )
- isValid = ( sNode._triangles[i].IsForward( newUV ) == refForward );
- }
+ newUV = surface->NextValueOfUV( sNode._uv, newXYZ, 10*tol ).XY();
+
+ // check validity of the newUV
+ for ( size_t i = 0; i < sNode._triangles.size() && isValid; ++i )
+ isValid = ( sNode._triangles[i].IsForward( newUV ) == refForward );
}
if ( !isValid )
{
if ( isValid )
{
sNode._uv = newUV;
- sNode._xyz = surface->Value( newUV.X(), newUV.Y() ).XYZ();
+ sNode._xyz = surface->Value( newUV ).XYZ();
}
}
}
continue; // not movable node
SMDS_MeshNode* node = const_cast< SMDS_MeshNode*>( n2sn->first );
- gp_Pnt xyz = surface->Value( sNode._uv.X(), sNode._uv.Y() );
+ gp_Pnt xyz = surface->Value( sNode._uv );
meshDS->MoveNode( node, xyz.X(), xyz.Y(), xyz.Z() );
// store the new UV
if ( node->getshapeId() != myHelper->GetSubShapeID() )
continue; // medium node is on EDGE or VERTEX
- gp_XY uv1 = myHelper->GetNodeUV( geomFace, link.node1(), node );
- gp_XY uv2 = myHelper->GetNodeUV( geomFace, link.node2(), node );
+ gp_XYZ pm = 0.5 * ( SMESH_TNodeXYZ( link.node1() ) + SMESH_TNodeXYZ( link.node2() ));
+ gp_XY uvm = myHelper->GetNodeUV( quad->face, node );
+
+ gp_Pnt2d uv = surface->NextValueOfUV( uvm, pm, 10*tol );
+ gp_Pnt xyz = surface->Value( uv );
- gp_XY uv = myHelper->GetMiddleUV( surface, uv1, uv2 );
node->SetPosition( SMDS_PositionPtr( new SMDS_FacePosition( uv.X(), uv.Y() )));
-
- gp_Pnt xyz = surface->Value( uv.X(), uv.Y() );
meshDS->MoveNode( node, xyz.X(), xyz.Y(), xyz.Z() );
}
}
if ( !myHelper->IsSeamShape( nn[i]->getshapeId() ))
nInFace = nn[i];
+ toCheckUV = true;
for ( int i = 0; i < nbN; ++i )
uv[ i ] = myHelper->GetNodeUV( geomFace, nn[i], nInFace, &toCheckUV );
if ( !theConsiderMesh || faceSide.VertexNode( iE ))
{
TopoDS_Vertex v = helper.IthVertex( 0, *edge );
- double angle = SMESH_MesherHelper::GetAngle( prevE, *edge, theFace, v );
+ double angle = helper.GetAngle( prevE, *edge, theFace, v );
vertexByAngle.insert( make_pair( angle, v ));
angleByVertex.Bind( v, angle );
}
Standard_Real u1,u2,v1,v2;
const TopoDS_Face& face = TopoDS::Face( myHelper->GetSubShape() );
const double tol = BRep_Tool::Tolerance( face );
- Handle(Geom_Surface) surf = BRep_Tool::Surface( face );
- surf->Bounds( u1,u2,v1,v2 );
- GeomAPI_ProjectPointOnSurf project;
- project.Init(surf, u1,u2, v1,v2, tol );
+ Handle(ShapeAnalysis_Surface) project = myHelper->GetSurface( face );
+ project->Bounds( u1,u2,v1,v2 );
Bnd_Box bbox;
BRepBndLib::Add( face, bbox );
double farTol = 0.01 * sqrt( bbox.SquareExtent() );
+ // get internal VERTEXes of the FACE to use them instead of equal points
+ typedef map< pair< double, double >, TopoDS_Vertex > TUV2VMap;
+ TUV2VMap uv2intV;
+ for ( TopExp_Explorer vExp( face, TopAbs_VERTEX, TopAbs_EDGE ); vExp.More(); vExp.Next() )
+ {
+ TopoDS_Vertex v = TopoDS::Vertex( vExp.Current() );
+ gp_Pnt2d uv = project->ValueOfUV( BRep_Tool::Pnt( v ), tol );
+ uv2intV.insert( make_pair( make_pair( uv.X(), uv.Y() ), v ));
+ }
+
for ( size_t iP = 0; iP < points.size(); ++iP )
{
- project.Perform( points[ iP ]);
- if ( !project.IsDone() )
- {
- if ( isStrictCheck && iP < nbPoints )
- return error
- (TComm("Projection of an enforced point to the face failed - (")
- << points[ iP ].X() << ", "<< points[ iP ].Y() << ", "<< points[ iP ].Z() << " )");
- continue;
- }
- if ( project.LowerDistance() > farTol )
+ gp_Pnt2d uv = project->ValueOfUV( points[ iP ], tol );
+ if ( project->Gap() > farTol )
{
if ( isStrictCheck && iP < nbPoints )
return error
(COMPERR_BAD_PARMETERS, TComm("An enforced point is too far from the face, dist = ")
- << project.LowerDistance() << " - ("
+ << points[ iP ].Distance( project->Value( uv )) << " - ("
<< points[ iP ].X() << ", "<< points[ iP ].Y() << ", "<< points[ iP ].Z() << " )");
continue;
}
- Quantity_Parameter u, v;
- project.LowerDistanceParameters(u, v);
- gp_Pnt2d uv( u, v );
BRepClass_FaceClassifier clsf ( face, uv, tol );
switch ( clsf.State() ) {
case TopAbs_IN:
{
- double edgeDist = ( Min( Abs( u - u1 ), Abs( u - u2 )) +
- Min( Abs( v - v1 ), Abs( v - v2 )));
+ double edgeDist = ( Min( Abs( uv.X() - u1 ), Abs( uv.X() - u2 )) +
+ Min( Abs( uv.Y() - v1 ), Abs( uv.Y() - v2 )));
ForcedPoint fp;
fp.uv = uv.XY();
fp.xyz = points[ iP ].XYZ();
if ( iP >= nbPoints )
fp.vertex = TopoDS::Vertex( vMap( iP - nbPoints + 1 ));
+ TUV2VMap::iterator uv2v = uv2intV.lower_bound( make_pair( uv.X()-tol, uv.Y()-tol ));
+ for ( ; uv2v != uv2intV.end() && uv2v->first.first <= uv.X()+tol; ++uv2v )
+ if ( uv.SquareDistance( gp_Pnt2d( uv2v->first.first, uv2v->first.second )) < tol*tol )
+ {
+ fp.vertex = uv2v->second;
+ break;
+ }
+
+ fp.node = 0;
+ if ( myHelper->IsSubShape( fp.vertex, myHelper->GetMesh() ))
+ {
+ SMESH_subMesh* sm = myHelper->GetMesh()->GetSubMesh( fp.vertex );
+ sm->ComputeStateEngine( SMESH_subMesh::COMPUTE );
+ fp.node = SMESH_Algo::VertexNode( fp.vertex, myHelper->GetMeshDS() );
+ }
+ else
+ {
+ fp.node = myHelper->AddNode( fp.xyz.X(), fp.xyz.Y(), fp.xyz.Z(),
+ 0, fp.uv.X(), fp.uv.Y() );
+ }
sortedFP.insert( make_pair( edgeDist, fp ));
break;
}
{
bool isNodeEnforced = false;
- // look for a quad enclosing a enforced point
+ // look for a quad enclosing an enforced point
for ( quadIt = myQuadList.begin(); quadIt != myQuadList.end(); ++quadIt )
{
FaceQuadStruct::Ptr quad = *quadIt;
}
// make a node of a side forced
vector<UVPtStruct>& points = (vector<UVPtStruct>&) side.GetUVPtStruct();
- points[ sideNodeIndex ].u = myForcedPnts[ iFP ].U();
- points[ sideNodeIndex ].v = myForcedPnts[ iFP ].V();
+ points[ sideNodeIndex ].u = myForcedPnts[ iFP ].U();
+ points[ sideNodeIndex ].v = myForcedPnts[ iFP ].V();
+ points[ sideNodeIndex ].node = myForcedPnts[ iFP ].node;
updateSideUV( side, sideNodeIndex, quadsBySide );
FaceQuadStruct::Ptr newQuad = myQuadList.back();
FaceQuadStruct::Side& newSide = newQuad->side[ iNewSide ];
+ vector<UVPtStruct>& points = (vector<UVPtStruct>&) newSide.GetUVPtStruct();
+ points[ indForced ].node = myForcedPnts[ iFP ].node;
+
newSide.forced_nodes.insert( indForced );
quad->side[( iNewSide+2 ) % 4 ].forced_nodes.insert( indForced );
<< myForcedPnts[iFP].xyz.Y() << ", "
<< myForcedPnts[iFP].xyz.Z() << " )");
}
+ myNeedSmooth = true;
} // loop on enforced points
if ( quadVec.size() <= 1 )
continue; // outer side
- bool missedNodesOnSide = false;
const vector<UVPtStruct>& points = side.grid->GetUVPtStruct();
for ( size_t iC = 0; iC < side.contacts.size(); ++iC )
{
+ if ( side.contacts[iC].point < side.from ||
+ side.contacts[iC].point >= side.to )
+ continue;
+ if ( side.contacts[iC].other_point < side.contacts[iC].other_side->from ||
+ side.contacts[iC].other_point >= side.contacts[iC].other_side->to )
+ continue;
const vector<UVPtStruct>& oGrid = side.contacts[iC].other_side->grid->GetUVPtStruct();
const UVPtStruct& uvPt = points[ side.contacts[iC].point ];
- if ( side.contacts[iC].other_point >= oGrid.size() ||
+ if ( side.contacts[iC].other_point >= oGrid .size() ||
side.contacts[iC].point >= points.size() )
throw SALOME_Exception( "StdMeshers_Quadrangle_2D::addEnforcedNodes(): wrong contact" );
if ( oGrid[ side.contacts[iC].other_point ].node )
(( UVPtStruct& ) uvPt).node = oGrid[ side.contacts[iC].other_point ].node;
}
+
+ bool missedNodesOnSide = false;
for ( size_t iP = 0; iP < points.size(); ++iP )
if ( !points[ iP ].node )
{
UVPtStruct& uvPnt = ( UVPtStruct& ) points[ iP ];
- gp_Pnt P = surf->Value( uvPnt.u, uvPnt.v );
- uvPnt.node = meshDS->AddNode(P.X(), P.Y(), P.Z());
- meshDS->SetNodeOnFace( uvPnt.node, myHelper->GetSubShapeID(), uvPnt.u, uvPnt.v );
+ gp_Pnt P = surf->Value( uvPnt.u, uvPnt.v );
+ uvPnt.node = myHelper->AddNode(P.X(), P.Y(), P.Z(), 0, uvPnt.u, uvPnt.v );
missedNodesOnSide = true;
}
if ( missedNodesOnSide )
newQuad->side[ QUAD_TOP_SIDE ].from = iTop;
newQuad->name = ( TComm("Right of I=") << I );
- quad->side[ QUAD_BOTTOM_SIDE ].to = iBot + 1;
- quad->side[ QUAD_TOP_SIDE ].to = iTop + 1;
+ bool bRev = quad->side[ QUAD_BOTTOM_SIDE ].IsReversed();
+ bool tRev = quad->side[ QUAD_TOP_SIDE ].IsReversed();
+ quad->side[ QUAD_BOTTOM_SIDE ].to = iBot + ( bRev ? -1 : +1 );
+ quad->side[ QUAD_TOP_SIDE ].to = iTop + ( tRev ? -1 : +1 );
quad->uv_grid.clear();
return QUAD_LEFT_SIDE;
if ( ip >= GetUVPtStruct().size() ||
iop >= side->GetUVPtStruct().size() )
throw SALOME_Exception( "FaceQuadStruct::Side::AddContact(): wrong point" );
+ if ( ip < from || ip >= to )
+ return;
{
contacts.resize( contacts.size() + 1 );
Contact& c = contacts.back();