mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-11 16:19:16 +05:00
[bos #42851][CEA][Windows] SMESH compilation broken. Classifier class moved from a source file to a separated header, so templates could know its size on compile time (we had an error with forward declaration). Added numeric header.
This commit is contained in:
parent
ce3633a7df
commit
df79d42e30
@ -51,6 +51,7 @@ SET(_link_LIBRARIES
|
|||||||
# header files / no moc processing
|
# header files / no moc processing
|
||||||
SET(SMESHControls_HEADERS
|
SET(SMESHControls_HEADERS
|
||||||
SMESH_ControlsDef.hxx
|
SMESH_ControlsDef.hxx
|
||||||
|
SMESH_ControlsClassifier.hxx
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- sources ---
|
# --- sources ---
|
||||||
@ -58,6 +59,7 @@ SET(SMESHControls_HEADERS
|
|||||||
# sources / static
|
# sources / static
|
||||||
SET(SMESHControls_SOURCES
|
SET(SMESHControls_SOURCES
|
||||||
SMESH_Controls.cxx
|
SMESH_Controls.cxx
|
||||||
|
SMESH_ControlsClassifier.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- rules ---
|
# --- rules ---
|
||||||
|
@ -40,10 +40,7 @@
|
|||||||
#include <Basics_Utils.hxx>
|
#include <Basics_Utils.hxx>
|
||||||
|
|
||||||
#include <BRepAdaptor_Surface.hxx>
|
#include <BRepAdaptor_Surface.hxx>
|
||||||
#include <BRepBndLib.hxx>
|
|
||||||
#include <BRepBuilderAPI_Copy.hxx>
|
#include <BRepBuilderAPI_Copy.hxx>
|
||||||
#include <BRepClass3d_SolidClassifier.hxx>
|
|
||||||
#include <BRepClass_FaceClassifier.hxx>
|
|
||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
#include <GeomLib_IsPlanarSurface.hxx>
|
#include <GeomLib_IsPlanarSurface.hxx>
|
||||||
#include <Geom_CylindricalSurface.hxx>
|
#include <Geom_CylindricalSurface.hxx>
|
||||||
@ -4493,58 +4490,14 @@ bool ElementsOnSurface::isOnSurface( const SMDS_MeshNode* theNode )
|
|||||||
// ElementsOnShape
|
// ElementsOnShape
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
namespace {
|
|
||||||
const int theIsCheckedFlag = 0x0000100;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ElementsOnShape::Classifier
|
|
||||||
{
|
|
||||||
Classifier(): mySolidClfr(0), myProjFace(0), myProjEdge(0), myFlags(0) { myU = myV = 1e100; }
|
|
||||||
~Classifier();
|
|
||||||
void Init(const TopoDS_Shape& s, double tol, const Bnd_B3d* box = 0 );
|
|
||||||
bool IsOut(const gp_Pnt& p) { return SetChecked( true ), (this->*myIsOutFun)( p ); }
|
|
||||||
TopAbs_ShapeEnum ShapeType() const { return myShape.ShapeType(); }
|
|
||||||
const TopoDS_Shape& Shape() const { return myShape; }
|
|
||||||
const Bnd_B3d* GetBndBox() const { return & myBox; }
|
|
||||||
double Tolerance() const { return myTol; }
|
|
||||||
bool IsChecked() { return myFlags & theIsCheckedFlag; }
|
|
||||||
bool IsSetFlag( int flag ) const { return myFlags & flag; }
|
|
||||||
void SetChecked( bool is ) { is ? SetFlag( theIsCheckedFlag ) : UnsetFlag( theIsCheckedFlag ); }
|
|
||||||
void SetFlag ( int flag ) { myFlags |= flag; }
|
|
||||||
void UnsetFlag( int flag ) { myFlags &= ~flag; }
|
|
||||||
void GetParams( double & u, double & v ) const { u = myU; v = myV; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool isOutOfSolid (const gp_Pnt& p);
|
|
||||||
bool isOutOfBox (const gp_Pnt& p);
|
|
||||||
bool isOutOfFace (const gp_Pnt& p);
|
|
||||||
bool isOutOfEdge (const gp_Pnt& p);
|
|
||||||
bool isOutOfVertex(const gp_Pnt& p);
|
|
||||||
bool isOutOfNone (const gp_Pnt& /*p*/) { return true; }
|
|
||||||
bool isBox (const TopoDS_Shape& s);
|
|
||||||
|
|
||||||
TopoDS_Shape prepareSolid( const TopoDS_Shape& theSolid );
|
|
||||||
|
|
||||||
bool (Classifier::* myIsOutFun)(const gp_Pnt& p);
|
|
||||||
BRepClass3d_SolidClassifier* mySolidClfr;
|
|
||||||
Bnd_B3d myBox;
|
|
||||||
GeomAPI_ProjectPointOnSurf* myProjFace;
|
|
||||||
GeomAPI_ProjectPointOnCurve* myProjEdge;
|
|
||||||
gp_Pnt myVertexXYZ;
|
|
||||||
TopoDS_Shape myShape;
|
|
||||||
double myTol;
|
|
||||||
double myU, myV; // result of isOutOfFace() and isOutOfEdge()
|
|
||||||
int myFlags;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ElementsOnShape::OctreeClassifier : public SMESH_Octree
|
struct ElementsOnShape::OctreeClassifier : public SMESH_Octree
|
||||||
{
|
{
|
||||||
OctreeClassifier( const std::vector< ElementsOnShape::Classifier* >& classifiers );
|
OctreeClassifier( const std::vector< Classifier* >& classifiers );
|
||||||
OctreeClassifier( const OctreeClassifier* otherTree,
|
OctreeClassifier( const OctreeClassifier* otherTree,
|
||||||
const std::vector< ElementsOnShape::Classifier >& clsOther,
|
const std::vector< Classifier >& clsOther,
|
||||||
std::vector< ElementsOnShape::Classifier >& cls );
|
std::vector< Classifier >& cls );
|
||||||
void GetClassifiersAtPoint( const gp_XYZ& p,
|
void GetClassifiersAtPoint( const gp_XYZ& p,
|
||||||
std::vector< ElementsOnShape::Classifier* >& classifiers );
|
std::vector< Classifier* >& classifiers );
|
||||||
size_t GetSize();
|
size_t GetSize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -4553,7 +4506,7 @@ protected:
|
|||||||
void buildChildrenData();
|
void buildChildrenData();
|
||||||
Bnd_B3d* buildRootBox();
|
Bnd_B3d* buildRootBox();
|
||||||
|
|
||||||
std::vector< ElementsOnShape::Classifier* > myClassifiers;
|
std::vector< Classifier* > myClassifiers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -4867,199 +4820,8 @@ bool ElementsOnShape::IsSatisfy (const SMDS_MeshNode* node,
|
|||||||
return !isNodeOut;
|
return !isNodeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementsOnShape::Classifier::Init( const TopoDS_Shape& theShape,
|
|
||||||
double theTol,
|
|
||||||
const Bnd_B3d* theBox )
|
|
||||||
{
|
|
||||||
myShape = theShape;
|
|
||||||
myTol = theTol;
|
|
||||||
myFlags = 0;
|
|
||||||
|
|
||||||
bool isShapeBox = false;
|
|
||||||
switch ( myShape.ShapeType() )
|
|
||||||
{
|
|
||||||
case TopAbs_SOLID:
|
|
||||||
{
|
|
||||||
if (( isShapeBox = isBox( theShape )))
|
|
||||||
{
|
|
||||||
myIsOutFun = & ElementsOnShape::Classifier::isOutOfBox;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mySolidClfr = new BRepClass3d_SolidClassifier( prepareSolid( theShape ));
|
|
||||||
myIsOutFun = & ElementsOnShape::Classifier::isOutOfSolid;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TopAbs_FACE:
|
|
||||||
{
|
|
||||||
Standard_Real u1,u2,v1,v2;
|
|
||||||
Handle(Geom_Surface) surf = BRep_Tool::Surface( TopoDS::Face( theShape ));
|
|
||||||
if ( surf.IsNull() )
|
|
||||||
myIsOutFun = & ElementsOnShape::Classifier::isOutOfNone;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
surf->Bounds( u1,u2,v1,v2 );
|
|
||||||
myProjFace = new GeomAPI_ProjectPointOnSurf;
|
|
||||||
myProjFace->Init( surf, u1,u2, v1,v2, myTol );
|
|
||||||
myIsOutFun = & ElementsOnShape::Classifier::isOutOfFace;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TopAbs_EDGE:
|
|
||||||
{
|
|
||||||
Standard_Real u1, u2;
|
|
||||||
Handle(Geom_Curve) curve = BRep_Tool::Curve( TopoDS::Edge( theShape ), u1, u2);
|
|
||||||
if ( curve.IsNull() )
|
|
||||||
myIsOutFun = & ElementsOnShape::Classifier::isOutOfNone;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
myProjEdge = new GeomAPI_ProjectPointOnCurve;
|
|
||||||
myProjEdge->Init( curve, u1, u2 );
|
|
||||||
myIsOutFun = & ElementsOnShape::Classifier::isOutOfEdge;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TopAbs_VERTEX:
|
|
||||||
{
|
|
||||||
myVertexXYZ = BRep_Tool::Pnt( TopoDS::Vertex( theShape ) );
|
|
||||||
myIsOutFun = & ElementsOnShape::Classifier::isOutOfVertex;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
throw SALOME_Exception("Programmer error in usage of ElementsOnShape::Classifier");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !isShapeBox )
|
|
||||||
{
|
|
||||||
if ( theBox )
|
|
||||||
{
|
|
||||||
myBox = *theBox;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Bnd_Box box;
|
|
||||||
if ( myShape.ShapeType() == TopAbs_FACE )
|
|
||||||
{
|
|
||||||
BRepAdaptor_Surface SA( TopoDS::Face( myShape ), /*useBoundaries=*/false );
|
|
||||||
if ( SA.GetType() == GeomAbs_BSplineSurface )
|
|
||||||
BRepBndLib::AddOptimal( myShape, box,
|
|
||||||
/*useTriangulation=*/true, /*useShapeTolerance=*/true );
|
|
||||||
}
|
|
||||||
if ( box.IsVoid() )
|
|
||||||
BRepBndLib::Add( myShape, box );
|
|
||||||
myBox.Clear();
|
|
||||||
myBox.Add( box.CornerMin() );
|
|
||||||
myBox.Add( box.CornerMax() );
|
|
||||||
gp_XYZ halfSize = 0.5 * ( box.CornerMax().XYZ() - box.CornerMin().XYZ() );
|
|
||||||
for ( int iDim = 1; iDim <= 3; ++iDim )
|
|
||||||
{
|
|
||||||
double x = halfSize.Coord( iDim );
|
|
||||||
halfSize.SetCoord( iDim, x + Max( myTol, 1e-2 * x ));
|
|
||||||
}
|
|
||||||
myBox.SetHSize( halfSize );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ElementsOnShape::Classifier::~Classifier()
|
|
||||||
{
|
|
||||||
delete mySolidClfr; mySolidClfr = 0;
|
|
||||||
delete myProjFace; myProjFace = 0;
|
|
||||||
delete myProjEdge; myProjEdge = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
TopoDS_Shape ElementsOnShape::Classifier::prepareSolid( const TopoDS_Shape& theSolid )
|
|
||||||
{
|
|
||||||
// try to limit tolerance of theSolid down to myTol (issue #19026)
|
|
||||||
|
|
||||||
// check if tolerance of theSolid is more than myTol
|
|
||||||
bool tolIsOk = true; // max tolerance is at VERTEXes
|
|
||||||
for ( TopExp_Explorer exp( theSolid, TopAbs_VERTEX ); exp.More() && tolIsOk; exp.Next() )
|
|
||||||
tolIsOk = ( myTol >= BRep_Tool::Tolerance( TopoDS::Vertex( exp.Current() )));
|
|
||||||
if ( tolIsOk )
|
|
||||||
return theSolid;
|
|
||||||
|
|
||||||
// make a copy to prevent the original shape from changes
|
|
||||||
TopoDS_Shape resultShape = BRepBuilderAPI_Copy( theSolid );
|
|
||||||
|
|
||||||
if ( !GEOMUtils::FixShapeTolerance( resultShape, TopAbs_SHAPE, myTol ))
|
|
||||||
return theSolid;
|
|
||||||
return resultShape;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ElementsOnShape::Classifier::isOutOfSolid( const gp_Pnt& p )
|
|
||||||
{
|
|
||||||
if ( isOutOfBox( p )) return true;
|
|
||||||
mySolidClfr->Perform( p, myTol );
|
|
||||||
return ( mySolidClfr->State() != TopAbs_IN && mySolidClfr->State() != TopAbs_ON );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ElementsOnShape::Classifier::isOutOfBox( const gp_Pnt& p )
|
|
||||||
{
|
|
||||||
return myBox.IsOut( p.XYZ() );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ElementsOnShape::Classifier::isOutOfFace( const gp_Pnt& p )
|
|
||||||
{
|
|
||||||
if ( isOutOfBox( p )) return true;
|
|
||||||
myProjFace->Perform( p );
|
|
||||||
if ( myProjFace->IsDone() && myProjFace->LowerDistance() <= myTol )
|
|
||||||
{
|
|
||||||
// check relatively to the face
|
|
||||||
myProjFace->LowerDistanceParameters( myU, myV );
|
|
||||||
gp_Pnt2d aProjPnt( myU, myV );
|
|
||||||
BRepClass_FaceClassifier aClsf ( TopoDS::Face( myShape ), aProjPnt, myTol );
|
|
||||||
if ( aClsf.State() == TopAbs_IN || aClsf.State() == TopAbs_ON )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ElementsOnShape::Classifier::isOutOfEdge( const gp_Pnt& p )
|
|
||||||
{
|
|
||||||
if ( isOutOfBox( p )) return true;
|
|
||||||
myProjEdge->Perform( p );
|
|
||||||
bool isOn = ( myProjEdge->NbPoints() > 0 && myProjEdge->LowerDistance() <= myTol );
|
|
||||||
if ( isOn )
|
|
||||||
myU = myProjEdge->LowerDistanceParameter();
|
|
||||||
return !isOn;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ElementsOnShape::Classifier::isOutOfVertex( const gp_Pnt& p )
|
|
||||||
{
|
|
||||||
return ( myVertexXYZ.Distance( p ) > myTol );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ElementsOnShape::Classifier::isBox(const TopoDS_Shape& theShape )
|
|
||||||
{
|
|
||||||
TopTools_IndexedMapOfShape vMap;
|
|
||||||
TopExp::MapShapes( theShape, TopAbs_VERTEX, vMap );
|
|
||||||
if ( vMap.Extent() != 8 )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
myBox.Clear();
|
|
||||||
for ( int i = 1; i <= 8; ++i )
|
|
||||||
myBox.Add( BRep_Tool::Pnt( TopoDS::Vertex( vMap( i ))).XYZ() );
|
|
||||||
|
|
||||||
gp_XYZ pMin = myBox.CornerMin(), pMax = myBox.CornerMax();
|
|
||||||
for ( int i = 1; i <= 8; ++i )
|
|
||||||
{
|
|
||||||
gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( vMap( i )));
|
|
||||||
for ( int iC = 1; iC <= 3; ++ iC )
|
|
||||||
{
|
|
||||||
double d1 = Abs( pMin.Coord( iC ) - p.Coord( iC ));
|
|
||||||
double d2 = Abs( pMax.Coord( iC ) - p.Coord( iC ));
|
|
||||||
if ( Min( d1, d2 ) > myTol )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
myBox.Enlarge( myTol );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ElementsOnShape::
|
ElementsOnShape::
|
||||||
OctreeClassifier::OctreeClassifier( const std::vector< ElementsOnShape::Classifier* >& classifiers )
|
OctreeClassifier::OctreeClassifier( const std::vector< Classifier* >& classifiers )
|
||||||
:SMESH_Octree( new SMESH_TreeLimit )
|
:SMESH_Octree( new SMESH_TreeLimit )
|
||||||
{
|
{
|
||||||
myClassifiers = classifiers;
|
myClassifiers = classifiers;
|
||||||
@ -5068,8 +4830,8 @@ OctreeClassifier::OctreeClassifier( const std::vector< ElementsOnShape::Classifi
|
|||||||
|
|
||||||
ElementsOnShape::
|
ElementsOnShape::
|
||||||
OctreeClassifier::OctreeClassifier( const OctreeClassifier* otherTree,
|
OctreeClassifier::OctreeClassifier( const OctreeClassifier* otherTree,
|
||||||
const std::vector< ElementsOnShape::Classifier >& clsOther,
|
const std::vector< Classifier >& clsOther,
|
||||||
std::vector< ElementsOnShape::Classifier >& cls )
|
std::vector< Classifier >& cls )
|
||||||
:SMESH_Octree( new SMESH_TreeLimit )
|
:SMESH_Octree( new SMESH_TreeLimit )
|
||||||
{
|
{
|
||||||
myBox = new Bnd_B3d( *otherTree->getBox() );
|
myBox = new Bnd_B3d( *otherTree->getBox() );
|
||||||
@ -5095,7 +4857,7 @@ OctreeClassifier::OctreeClassifier( const OctreeClassifier*
|
|||||||
|
|
||||||
void ElementsOnShape::
|
void ElementsOnShape::
|
||||||
OctreeClassifier::GetClassifiersAtPoint( const gp_XYZ& point,
|
OctreeClassifier::GetClassifiersAtPoint( const gp_XYZ& point,
|
||||||
std::vector< ElementsOnShape::Classifier* >& result )
|
std::vector< Classifier* >& result )
|
||||||
{
|
{
|
||||||
if ( getBox()->IsOut( point ))
|
if ( getBox()->IsOut( point ))
|
||||||
return;
|
return;
|
||||||
|
233
src/Controls/SMESH_ControlsClassifier.cxx
Normal file
233
src/Controls/SMESH_ControlsClassifier.cxx
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
// Copyright (C) 2007-2024 CEA, EDF, 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, 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
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "SMESH_ControlsClassifier.hxx"
|
||||||
|
|
||||||
|
#include <GEOMUtils.hxx>
|
||||||
|
#include <Utils_SALOME_Exception.hxx>
|
||||||
|
|
||||||
|
#include <BRepClass3d_SolidClassifier.hxx>
|
||||||
|
#include <BRepClass_FaceClassifier.hxx>
|
||||||
|
#include <BRepBuilderAPI_Copy.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepBndLib.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <GeomAPI_ProjectPointOnSurf.hxx>
|
||||||
|
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||||
|
|
||||||
|
namespace SMESH
|
||||||
|
{
|
||||||
|
namespace Controls
|
||||||
|
{
|
||||||
|
void Classifier::Init( const TopoDS_Shape& theShape,
|
||||||
|
double theTol,
|
||||||
|
const Bnd_B3d* theBox )
|
||||||
|
{
|
||||||
|
myShape = theShape;
|
||||||
|
myTol = theTol;
|
||||||
|
myFlags = 0;
|
||||||
|
|
||||||
|
bool isShapeBox = false;
|
||||||
|
switch ( myShape.ShapeType() )
|
||||||
|
{
|
||||||
|
case TopAbs_SOLID:
|
||||||
|
{
|
||||||
|
if (( isShapeBox = isBox( theShape )))
|
||||||
|
{
|
||||||
|
myIsOutFun = & Classifier::isOutOfBox;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mySolidClfr = new BRepClass3d_SolidClassifier( prepareSolid( theShape ));
|
||||||
|
myIsOutFun = & Classifier::isOutOfSolid;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TopAbs_FACE:
|
||||||
|
{
|
||||||
|
Standard_Real u1,u2,v1,v2;
|
||||||
|
Handle(Geom_Surface) surf = BRep_Tool::Surface( TopoDS::Face( theShape ));
|
||||||
|
if ( surf.IsNull() )
|
||||||
|
myIsOutFun = & Classifier::isOutOfNone;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
surf->Bounds( u1,u2,v1,v2 );
|
||||||
|
myProjFace = new GeomAPI_ProjectPointOnSurf;
|
||||||
|
myProjFace->Init( surf, u1,u2, v1,v2, myTol );
|
||||||
|
myIsOutFun = & Classifier::isOutOfFace;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TopAbs_EDGE:
|
||||||
|
{
|
||||||
|
Standard_Real u1, u2;
|
||||||
|
Handle(Geom_Curve) curve = BRep_Tool::Curve( TopoDS::Edge( theShape ), u1, u2);
|
||||||
|
if ( curve.IsNull() )
|
||||||
|
myIsOutFun = & Classifier::isOutOfNone;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
myProjEdge = new GeomAPI_ProjectPointOnCurve;
|
||||||
|
myProjEdge->Init( curve, u1, u2 );
|
||||||
|
myIsOutFun = & Classifier::isOutOfEdge;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TopAbs_VERTEX:
|
||||||
|
{
|
||||||
|
myVertexXYZ = BRep_Tool::Pnt( TopoDS::Vertex( theShape ) );
|
||||||
|
myIsOutFun = & Classifier::isOutOfVertex;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw SALOME_Exception("Programmer error in usage of Classifier");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !isShapeBox )
|
||||||
|
{
|
||||||
|
if ( theBox )
|
||||||
|
{
|
||||||
|
myBox = *theBox;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Bnd_Box box;
|
||||||
|
if ( myShape.ShapeType() == TopAbs_FACE )
|
||||||
|
{
|
||||||
|
BRepAdaptor_Surface SA( TopoDS::Face( myShape ), /*useBoundaries=*/false );
|
||||||
|
if ( SA.GetType() == GeomAbs_BSplineSurface )
|
||||||
|
BRepBndLib::AddOptimal( myShape, box,
|
||||||
|
/*useTriangulation=*/true, /*useShapeTolerance=*/true );
|
||||||
|
}
|
||||||
|
if ( box.IsVoid() )
|
||||||
|
BRepBndLib::Add( myShape, box );
|
||||||
|
myBox.Clear();
|
||||||
|
myBox.Add( box.CornerMin() );
|
||||||
|
myBox.Add( box.CornerMax() );
|
||||||
|
gp_XYZ halfSize = 0.5 * ( box.CornerMax().XYZ() - box.CornerMin().XYZ() );
|
||||||
|
for ( int iDim = 1; iDim <= 3; ++iDim )
|
||||||
|
{
|
||||||
|
double x = halfSize.Coord( iDim );
|
||||||
|
halfSize.SetCoord( iDim, x + Max( myTol, 1e-2 * x ));
|
||||||
|
}
|
||||||
|
myBox.SetHSize( halfSize );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Classifier::~Classifier()
|
||||||
|
{
|
||||||
|
delete mySolidClfr; mySolidClfr = 0;
|
||||||
|
delete myProjFace; myProjFace = 0;
|
||||||
|
delete myProjEdge; myProjEdge = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TopoDS_Shape Classifier::prepareSolid( const TopoDS_Shape& theSolid )
|
||||||
|
{
|
||||||
|
// try to limit tolerance of theSolid down to myTol (issue #19026)
|
||||||
|
|
||||||
|
// check if tolerance of theSolid is more than myTol
|
||||||
|
bool tolIsOk = true; // max tolerance is at VERTEXes
|
||||||
|
for ( TopExp_Explorer exp( theSolid, TopAbs_VERTEX ); exp.More() && tolIsOk; exp.Next() )
|
||||||
|
tolIsOk = ( myTol >= BRep_Tool::Tolerance( TopoDS::Vertex( exp.Current() )));
|
||||||
|
if ( tolIsOk )
|
||||||
|
return theSolid;
|
||||||
|
|
||||||
|
// make a copy to prevent the original shape from changes
|
||||||
|
TopoDS_Shape resultShape = BRepBuilderAPI_Copy( theSolid );
|
||||||
|
|
||||||
|
if ( !GEOMUtils::FixShapeTolerance( resultShape, TopAbs_SHAPE, myTol ))
|
||||||
|
return theSolid;
|
||||||
|
return resultShape;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Classifier::isOutOfSolid( const gp_Pnt& p )
|
||||||
|
{
|
||||||
|
if ( isOutOfBox( p )) return true;
|
||||||
|
mySolidClfr->Perform( p, myTol );
|
||||||
|
return ( mySolidClfr->State() != TopAbs_IN && mySolidClfr->State() != TopAbs_ON );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Classifier::isOutOfBox( const gp_Pnt& p )
|
||||||
|
{
|
||||||
|
return myBox.IsOut( p.XYZ() );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Classifier::isOutOfFace( const gp_Pnt& p )
|
||||||
|
{
|
||||||
|
if ( isOutOfBox( p )) return true;
|
||||||
|
myProjFace->Perform( p );
|
||||||
|
if ( myProjFace->IsDone() && myProjFace->LowerDistance() <= myTol )
|
||||||
|
{
|
||||||
|
// check relatively to the face
|
||||||
|
myProjFace->LowerDistanceParameters( myU, myV );
|
||||||
|
gp_Pnt2d aProjPnt( myU, myV );
|
||||||
|
BRepClass_FaceClassifier aClsf ( TopoDS::Face( myShape ), aProjPnt, myTol );
|
||||||
|
if ( aClsf.State() == TopAbs_IN || aClsf.State() == TopAbs_ON )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Classifier::isOutOfEdge( const gp_Pnt& p )
|
||||||
|
{
|
||||||
|
if ( isOutOfBox( p )) return true;
|
||||||
|
myProjEdge->Perform( p );
|
||||||
|
bool isOn = ( myProjEdge->NbPoints() > 0 && myProjEdge->LowerDistance() <= myTol );
|
||||||
|
if ( isOn )
|
||||||
|
myU = myProjEdge->LowerDistanceParameter();
|
||||||
|
return !isOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Classifier::isOutOfVertex( const gp_Pnt& p )
|
||||||
|
{
|
||||||
|
return ( myVertexXYZ.Distance( p ) > myTol );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Classifier::isBox(const TopoDS_Shape& theShape )
|
||||||
|
{
|
||||||
|
TopTools_IndexedMapOfShape vMap;
|
||||||
|
TopExp::MapShapes( theShape, TopAbs_VERTEX, vMap );
|
||||||
|
if ( vMap.Extent() != 8 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
myBox.Clear();
|
||||||
|
for ( int i = 1; i <= 8; ++i )
|
||||||
|
myBox.Add( BRep_Tool::Pnt( TopoDS::Vertex( vMap( i ))).XYZ() );
|
||||||
|
|
||||||
|
gp_XYZ pMin = myBox.CornerMin(), pMax = myBox.CornerMax();
|
||||||
|
for ( int i = 1; i <= 8; ++i )
|
||||||
|
{
|
||||||
|
gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( vMap( i )));
|
||||||
|
for ( int iC = 1; iC <= 3; ++ iC )
|
||||||
|
{
|
||||||
|
double d1 = Abs( pMin.Coord( iC ) - p.Coord( iC ));
|
||||||
|
double d2 = Abs( pMax.Coord( iC ) - p.Coord( iC ));
|
||||||
|
if ( Min( d1, d2 ) > myTol )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myBox.Enlarge( myTol );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
83
src/Controls/SMESH_ControlsClassifier.hxx
Normal file
83
src/Controls/SMESH_ControlsClassifier.hxx
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// Copyright (C) 2007-2024 CEA, EDF, 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, 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
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef _SMESH_CONTROLSCLASSIFIER_HXX_
|
||||||
|
#define _SMESH_CONTROLSCLASSIFIER_HXX_
|
||||||
|
|
||||||
|
#include "SMESH_Controls.hxx"
|
||||||
|
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <Bnd_B3d.hxx>
|
||||||
|
|
||||||
|
class BRepClass3d_SolidClassifier;
|
||||||
|
class GeomAPI_ProjectPointOnSurf;
|
||||||
|
class GeomAPI_ProjectPointOnCurve;
|
||||||
|
|
||||||
|
namespace SMESH
|
||||||
|
{
|
||||||
|
namespace Controls
|
||||||
|
{
|
||||||
|
struct SMESHCONTROLS_EXPORT Classifier
|
||||||
|
{
|
||||||
|
Classifier(): mySolidClfr(0), myProjFace(0), myProjEdge(0), myFlags(0) { myU = myV = 1e100; }
|
||||||
|
~Classifier();
|
||||||
|
void Init(const TopoDS_Shape& s, double tol, const Bnd_B3d* box = 0 );
|
||||||
|
bool IsOut(const gp_Pnt& p) { return SetChecked( true ), (this->*myIsOutFun)( p ); }
|
||||||
|
TopAbs_ShapeEnum ShapeType() const { return myShape.ShapeType(); }
|
||||||
|
const TopoDS_Shape& Shape() const { return myShape; }
|
||||||
|
const Bnd_B3d* GetBndBox() const { return & myBox; }
|
||||||
|
double Tolerance() const { return myTol; }
|
||||||
|
bool IsChecked() { return myFlags & theIsCheckedFlag; }
|
||||||
|
bool IsSetFlag( int flag ) const { return myFlags & flag; }
|
||||||
|
void SetChecked( bool is ) { is ? SetFlag( theIsCheckedFlag ) : UnsetFlag( theIsCheckedFlag ); }
|
||||||
|
void SetFlag ( int flag ) { myFlags |= flag; }
|
||||||
|
void UnsetFlag( int flag ) { myFlags &= ~flag; }
|
||||||
|
void GetParams( double & u, double & v ) const { u = myU; v = myV; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isOutOfSolid (const gp_Pnt& p);
|
||||||
|
bool isOutOfBox (const gp_Pnt& p);
|
||||||
|
bool isOutOfFace (const gp_Pnt& p);
|
||||||
|
bool isOutOfEdge (const gp_Pnt& p);
|
||||||
|
bool isOutOfVertex(const gp_Pnt& p);
|
||||||
|
bool isOutOfNone (const gp_Pnt& /*p*/) { return true; }
|
||||||
|
bool isBox (const TopoDS_Shape& s);
|
||||||
|
|
||||||
|
TopoDS_Shape prepareSolid( const TopoDS_Shape& theSolid );
|
||||||
|
|
||||||
|
bool (Classifier::* myIsOutFun)(const gp_Pnt& p);
|
||||||
|
BRepClass3d_SolidClassifier* mySolidClfr;
|
||||||
|
Bnd_B3d myBox;
|
||||||
|
GeomAPI_ProjectPointOnSurf* myProjFace;
|
||||||
|
GeomAPI_ProjectPointOnCurve* myProjEdge;
|
||||||
|
gp_Pnt myVertexXYZ;
|
||||||
|
TopoDS_Shape myShape;
|
||||||
|
double myTol;
|
||||||
|
double myU, myV; // result of isOutOfFace() and isOutOfEdge()
|
||||||
|
int myFlags;
|
||||||
|
|
||||||
|
static const int theIsCheckedFlag = 0x0000100;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -26,6 +26,7 @@
|
|||||||
#include "SMESH_Controls.hxx"
|
#include "SMESH_Controls.hxx"
|
||||||
|
|
||||||
#include "SMESH_TypeDefs.hxx"
|
#include "SMESH_TypeDefs.hxx"
|
||||||
|
#include "SMESH_ControlsClassifier.hxx"
|
||||||
|
|
||||||
#include <Bnd_B3d.hxx>
|
#include <Bnd_B3d.hxx>
|
||||||
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||||
@ -988,7 +989,6 @@ namespace SMESH{
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct Classifier;
|
|
||||||
struct OctreeClassifier;
|
struct OctreeClassifier;
|
||||||
|
|
||||||
void clearClassifiers();
|
void clearClassifiers();
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
using namespace StdMeshers::Cartesian3D;
|
using namespace StdMeshers::Cartesian3D;
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include "StdMeshers_Cartesian_3D_Hexahedron.hxx"
|
#include "StdMeshers_Cartesian_3D_Hexahedron.hxx"
|
||||||
|
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace SMESH;
|
using namespace SMESH;
|
||||||
using namespace StdMeshers::Cartesian3D;
|
using namespace StdMeshers::Cartesian3D;
|
||||||
|
Loading…
Reference in New Issue
Block a user