-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019 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
// 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.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
//
#include "SMESH_Block.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_MeshVolume.hxx"
+#include "SMDS_VolumeTool.hxx"
+#include "SMESH_MeshAlgos.hxx"
+
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Curve2d.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <math_Matrix.hxx>
#include <math_Vector.hxx>
-#include "SMDS_MeshNode.hxx"
-#include "SMDS_MeshVolume.hxx"
-#include "SMDS_VolumeTool.hxx"
-#include "utilities.h"
+#include <utilities.h>
#include <list>
#include <limits>
// pcurves
vector< int > edgeIdVec;
GetFaceEdgesIDs( faceID, edgeIdVec );
- for ( int iE = 0; iE < edgeIdVec.size(); iE++ ) // loop on 4 edges
+ for ( size_t iE = 0; iE < edgeIdVec.size(); iE++ ) // loop on 4 edges
{
myCoordInd[ iE ] = GetCoordIndOnEdge( edgeIdVec[ iE ] );
if ( myC2d[ iE ]) delete myC2d[ iE ];
namespace
{
+ inline
bool isPntInTria( const gp_XY& p, const gp_XY& t0, const gp_XY& t1, const gp_XY& t2 )
{
- const double // matrix 2x2
- T11 = t0.X()-t2.X(), T12 = t1.X()-t2.X(),
- T21 = t0.Y()-t2.Y(), T22 = t1.Y()-t2.Y();
- const double Tdet = T11*T22 - T12*T21; // matrix determinant
- if ( Abs( Tdet ) < std::numeric_limits<double>::min() )
- return false;
- // matrix inverse
- const double t11 = T22, t12 = -T12, t21 = -T21, t22 = T11;
- // vector
- const double r11 = p.X()-t2.X(), r12 = p.Y()-t2.Y();
- // barycentric coordinates: mutiply matrix by vector
- const double bc0 = (t11 * r11 + t12 * r12)/Tdet;
- const double bc1 = (t21 * r11 + t22 * r12)/Tdet;
+ double bc0, bc1;
+ SMESH_MeshAlgos::GetBarycentricCoords( p, t0, t1, t2, bc0, bc1 );
return ( bc0 >= 0. && bc1 >= 0. && bc0 + bc1 <= 1. );
}
+ inline
bool isPntInQuad( const gp_XY& p,
const gp_XY& q0, const gp_XY& q1, const gp_XY& q2, const gp_XY& q3 )
{
if ( mag > DBL_MIN )
dPi /= mag;
drv[ iP - 1 ] = dPi;
+ // drv[ iP - 1 ] = dPi / 0.001;
}
for ( int iP = 0; iP < 3; iP++ ) {
#if 1
const bool isOnFace = IsFaceID( theShapeID );
double * coef = GetShapeCoef( theShapeID );
- // Find the first guess paremeters
+ // Find the first guess parameters
gp_XYZ start(0, 0, 0);
bool hasHint = ( 0 <= theParamsHint.X() && theParamsHint.X() <= 1 &&
0 <= theParamsHint.Y() && theParamsHint.Y() <= 1 &&
- 0 <= theParamsHint.Y() && theParamsHint.Y() <= 1 );
+ 0 <= theParamsHint.Z() && theParamsHint.Z() <= 1 );
if ( !hasHint && !myGridComputed )
{
// define the first guess by thePoint projection on lines
{
// find UV of thePoint on the FACE
Standard_Real U,V;
+ U=V=0;
const TFace& tface = myFace[ theFaceID - ID_FirstF ];
if ( !tface.Surface() ) return;
dy *= 1.2;
xSol = 0.5 * (xMax + xMin) ;
ySol = 0.5 * (yMax + yMin) ;
- if ( xMin == 0. && yMin == 0. && xMax == 1. && yMax == 1. ) // avoid infinit loop
+ if ( xMin == 0. && yMin == 0. && xMax == 1. && yMax == 1. ) // avoid infinite loop
{
#ifdef _DEBUG_REFINE_
cout << "SMESH_Block::refineParametersOnFace(): tface.IsUVInQuad() fails" << endl;
}
}
- // refine solution using half-division technic
+ // refine solution using half-division technique
gp_XYZ sol = theParams;
if ( saveBetterSolution( sol, theParams, thePoint.SquareDistance( tface.Point( sol ))))
{
#ifdef _DEBUG_REFINE_
- cout << "SMESH_Block::refineParametersOnFace(): dividing suceeded" << endl;
+ cout << "SMESH_Block::refineParametersOnFace(): dividing succeeded" << endl;
cout << " nbGetUV = " << nbGetUV << endl;
#endif
return true;
/*!
* \brief Return number of wires and a list of oredered edges.
* \param theFace - the face to process
- * \param theEdges - all ordered edges of theFace (outer edges goes first).
+ * \param theEdges - all ordered edges of theFace (outer edges go first).
* \param theNbEdgesInWires - nb of edges (== nb of vertices in closed wire) in each wire
* \param theFirstVertex - the vertex of the outer wire to set first in the returned
* list ( theFirstVertex may be NULL )
}
//================================================================================
/*!
- * \brief Call it after geometry initialisation
+ * \brief Call it after geometry initialization
*/
//================================================================================
const int theNode001Index,
vector<const SMDS_MeshNode*>& theOrderedNodes)
{
- MESSAGE(" ::LoadMeshBlock()");
init();
SMDS_VolumeTool vTool;
//function : LoadBlockShapes
//purpose : Initialize block geometry with theShell,
// add sub-shapes of theBlock to theShapeIDMap so that they get
-// IDs acoording to enum TShapeID
+// IDs according to enum TShapeID
//=======================================================================
bool SMESH_Block::LoadBlockShapes(const TopoDS_Shell& theShell,
const TopoDS_Vertex& theVertex001,
TopTools_IndexedMapOfOrientedShape& theShapeIDMap )
{
- MESSAGE(" ::LoadBlockShapes()");
return ( FindBlockShapes( theShell, theVertex000, theVertex001, theShapeIDMap ) &&
LoadBlockShapes( theShapeIDMap ));
}
//=======================================================================
//function : LoadBlockShapes
//purpose : add sub-shapes of theBlock to theShapeIDMap so that they get
-// IDs acoording to enum TShapeID
+// IDs according to enum TShapeID
//=======================================================================
bool SMESH_Block::FindBlockShapes(const TopoDS_Shell& theShell,
const TopoDS_Vertex& theVertex001,
TopTools_IndexedMapOfOrientedShape& theShapeIDMap )
{
- MESSAGE(" ::FindBlockShapes()");
-
// 8 vertices
TopoDS_Shape V000, V100, V010, V110, V001, V101, V011, V111;
// 12 edges
if ( V000.IsNull() ) {
// find vertex 000 - the one with smallest coordinates
- double minVal = DBL_MAX, minX, val;
+ double minVal = DBL_MAX, minX = DBL_MAX, val;
for ( int i = 1; i <= 8; i++ ) {
const TopoDS_Vertex& v = TopoDS::Vertex( vfMap.FindKey( i ));
gp_Pnt P = BRep_Tool::Pnt( v );
for ( ; eIt.More(); eIt.Next() ) {
const TopoDS_Edge& e = TopoDS::Edge( eIt.Value() );
TopoDS_Vertex v = TopExp::FirstVertex( e );
- if ( v.IsSame( V000 ))
+ if ( v.IsSame( V000 )) {
v = TopExp::LastVertex( e );
+ if ( v.IsSame( V000 ))
+ return false;
+ }
val = dir001 * gp_Vec( p000, BRep_Tool::Pnt( v )).Normalized();
if ( val > maxVal ) {
V001 = v;
return false;
}
TopTools_ListIteratorOfListOfShape f001It, f000It ( f000List );
- int i, j, iFound1, iFound2;
+ int i, j, iFound1=0, iFound2=0;
for ( j = 0; f000It.More(); f000It.Next(), j++ )
{
if ( NB_FACES_BY_VERTEX == 6 && j % 2 ) continue; // each face encounters twice
bool isForward[4];
vector< int > edgeIdVec;
GetFaceEdgesIDs( theFaceID, edgeIdVec );
- for ( int iE = 0; iE < edgeIdVec.size(); iE++ ) // loop on 4 edges
+ for ( size_t iE = 0; iE < edgeIdVec.size(); iE++ ) // loop on 4 edges
{
if ( edgeIdVec[ iE ] > theShapeIDMap.Extent() )
return false;