mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-16 01:11:26 +05:00
Mantis issue 0020952: EDF 1505 GEOM: The type of the geometrical primitives from .step files
This commit is contained in:
parent
5d094b2282
commit
b659aaf41b
@ -18,11 +18,10 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
//
|
//
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
|
||||||
#ifndef _GEOMAlgo_KindOfShape_HeaderFile
|
#ifndef _GEOMAlgo_KindOfShape_HeaderFile
|
||||||
#define _GEOMAlgo_KindOfShape_HeaderFile
|
#define _GEOMAlgo_KindOfShape_HeaderFile
|
||||||
|
|
||||||
|
|
||||||
enum GEOMAlgo_KindOfShape {
|
enum GEOMAlgo_KindOfShape {
|
||||||
GEOMAlgo_KS_UNKNOWN,
|
GEOMAlgo_KS_UNKNOWN,
|
||||||
GEOMAlgo_KS_SPHERE,
|
GEOMAlgo_KS_SPHERE,
|
||||||
@ -34,7 +33,10 @@ GEOMAlgo_KS_ELLIPSE,
|
|||||||
GEOMAlgo_KS_PLANE,
|
GEOMAlgo_KS_PLANE,
|
||||||
GEOMAlgo_KS_CIRCLE,
|
GEOMAlgo_KS_CIRCLE,
|
||||||
GEOMAlgo_KS_LINE,
|
GEOMAlgo_KS_LINE,
|
||||||
GEOMAlgo_KS_DEGENERATED
|
GEOMAlgo_KS_DEGENERATED,
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 10:28:09 2012f
|
||||||
|
GEOMAlgo_KS_BSPLINE
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 10:28:11 2012t
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef _Standard_PrimitiveTypes_HeaderFile
|
#ifndef _Standard_PrimitiveTypes_HeaderFile
|
||||||
|
@ -15,11 +15,9 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
//
|
//
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
|
||||||
|
|
||||||
#include <GEOMAlgo_ShapeInfo.hxx>
|
#include <GEOMAlgo_ShapeInfo.hxx>
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType);
|
Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType);
|
||||||
static
|
static
|
||||||
@ -848,7 +846,8 @@ void DumpKindOfShape(const GEOMAlgo_KindOfShape aKS)
|
|||||||
"KS_PLANE",
|
"KS_PLANE",
|
||||||
"KS_CIRCLE",
|
"KS_CIRCLE",
|
||||||
"KS_LINE",
|
"KS_LINE",
|
||||||
"KS_DEGENERATED"
|
"KS_DEGENERATED",
|
||||||
|
"KS_BSPLINE"
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
//
|
//
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
//
|
//
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
|
||||||
|
|
||||||
#include <GEOMAlgo_ShapeInfoFiller.hxx>
|
#include <GEOMAlgo_ShapeInfoFiller.hxx>
|
||||||
|
|
||||||
@ -24,47 +23,36 @@
|
|||||||
#include <gp_Lin.hxx>
|
#include <gp_Lin.hxx>
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
#include <gp_Dir.hxx>
|
#include <gp_Dir.hxx>
|
||||||
|
|
||||||
#include <Geom_Curve.hxx>
|
|
||||||
#include <GeomAdaptor_Curve.hxx>
|
|
||||||
|
|
||||||
#include <TopoDS_Vertex.hxx>
|
|
||||||
#include <TopoDS.hxx>
|
|
||||||
#include <TopoDS_Edge.hxx>
|
|
||||||
|
|
||||||
#include <BRep_Tool.hxx>
|
|
||||||
#include <TopExp.hxx>
|
|
||||||
|
|
||||||
#include <TopTools_IndexedMapOfShape.hxx>
|
|
||||||
#include <gp_Circ.hxx>
|
#include <gp_Circ.hxx>
|
||||||
#include <gp_Ax2.hxx>
|
#include <gp_Ax2.hxx>
|
||||||
#include <gp_Elips.hxx>
|
#include <gp_Elips.hxx>
|
||||||
#include <TopoDS_Iterator.hxx>
|
|
||||||
#include <TopoDS_Wire.hxx>
|
|
||||||
#include <TopExp.hxx>
|
|
||||||
#include <Geom_Surface.hxx>
|
|
||||||
#include <TopoDS_Face.hxx>
|
|
||||||
#include <GeomAdaptor_Surface.hxx>
|
|
||||||
#include <gp_Pln.hxx>
|
|
||||||
#include <gp_Sphere.hxx>
|
#include <gp_Sphere.hxx>
|
||||||
#include <gp_Ax3.hxx>
|
#include <gp_Ax3.hxx>
|
||||||
#include <BRepTools.hxx>
|
|
||||||
#include <gp_Cylinder.hxx>
|
#include <gp_Cylinder.hxx>
|
||||||
#include <gp_Cone.hxx>
|
#include <gp_Cone.hxx>
|
||||||
#include <gp_Torus.hxx>
|
#include <gp_Torus.hxx>
|
||||||
|
#include <gp_Pln.hxx>
|
||||||
|
|
||||||
|
#include <Geom_Curve.hxx>
|
||||||
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <Geom_BSplineCurve.hxx>
|
||||||
|
|
||||||
|
#include <GeomAdaptor_Curve.hxx>
|
||||||
|
#include <GeomAdaptor_Surface.hxx>
|
||||||
|
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
#include <TopoDS_Solid.hxx>
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
#include <TopoDS_Wire.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
|
||||||
static
|
|
||||||
Standard_Boolean IsAllowedType(const GeomAbs_CurveType aCT);
|
|
||||||
static
|
|
||||||
Standard_Boolean IsAllowedType(const GeomAbs_SurfaceType aST);
|
|
||||||
static
|
|
||||||
Standard_Integer NbWires(const TopoDS_Face& aF);
|
|
||||||
static
|
|
||||||
Standard_Integer NbShells(const TopoDS_Solid& aS);
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function :
|
//function :
|
||||||
@ -215,7 +203,7 @@ static
|
|||||||
TopoDS_Iterator aIt;
|
TopoDS_Iterator aIt;
|
||||||
//
|
//
|
||||||
aIt.Initialize(aS);
|
aIt.Initialize(aS);
|
||||||
for (; aIt.More(); aIt.Next()){
|
for (; aIt.More(); aIt.Next()) {
|
||||||
const TopoDS_Shape& aSx=aIt.Value();
|
const TopoDS_Shape& aSx=aIt.Value();
|
||||||
FillShape(aSx);
|
FillShape(aSx);
|
||||||
}
|
}
|
||||||
@ -291,7 +279,7 @@ static
|
|||||||
//
|
//
|
||||||
aSd=TopoDS::Solid(aS);
|
aSd=TopoDS::Solid(aS);
|
||||||
//
|
//
|
||||||
aNbShells=NbShells(aSd);
|
aNbShells=GEOMAlgo_ShapeInfoFiller::NbShells(aSd);
|
||||||
if (aNbShells>1) {
|
if (aNbShells>1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -335,12 +323,12 @@ static
|
|||||||
//
|
//
|
||||||
aF=TopoDS::Face(aS);
|
aF=TopoDS::Face(aS);
|
||||||
//
|
//
|
||||||
aNbWires=NbWires(aF);
|
aNbWires=GEOMAlgo_ShapeInfoFiller::NbWires(aF);
|
||||||
//
|
//
|
||||||
aSurf=BRep_Tool::Surface(aF);
|
aSurf=BRep_Tool::Surface(aF);
|
||||||
GeomAdaptor_Surface aGAS(aSurf);
|
GeomAdaptor_Surface aGAS(aSurf);
|
||||||
aST=aGAS.GetType();
|
aST=aGAS.GetType();
|
||||||
bIsAllowedType=IsAllowedType(aST);
|
bIsAllowedType=GEOMAlgo_ShapeInfoFiller::IsAllowedType(aST);
|
||||||
if (!bIsAllowedType) {
|
if (!bIsAllowedType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -358,7 +346,9 @@ static
|
|||||||
aInfo.SetLocation(aP0);
|
aInfo.SetLocation(aP0);
|
||||||
aInfo.SetPosition(aAx3);
|
aInfo.SetPosition(aAx3);
|
||||||
//
|
//
|
||||||
if (aNbWires>1) return;
|
if (aNbWires>1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
//aSurf->Bounds(aUMin, aUMax, aVMin, aVMax);
|
//aSurf->Bounds(aUMin, aUMax, aVMin, aVMax);
|
||||||
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
|
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
|
||||||
@ -392,7 +382,9 @@ static
|
|||||||
aInfo.SetPosition(aAx3);
|
aInfo.SetPosition(aAx3);
|
||||||
aInfo.SetRadius1(aR1);
|
aInfo.SetRadius1(aR1);
|
||||||
//
|
//
|
||||||
if (aNbWires>1) return;
|
if (aNbWires>1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
|
aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
|
||||||
aInfo.SetKindOfClosed(GEOMAlgo_KC_CLOSED);
|
aInfo.SetKindOfClosed(GEOMAlgo_KC_CLOSED);
|
||||||
@ -414,7 +406,9 @@ static
|
|||||||
aInfo.SetPosition(aAx3);
|
aInfo.SetPosition(aAx3);
|
||||||
aInfo.SetRadius1(aR1);
|
aInfo.SetRadius1(aR1);
|
||||||
//
|
//
|
||||||
if (aNbWires>1) return;
|
if (aNbWires>1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
|
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
|
||||||
bInfU1=Precision::IsNegativeInfinite(aUMin);
|
bInfU1=Precision::IsNegativeInfinite(aUMin);
|
||||||
@ -446,7 +440,9 @@ static
|
|||||||
aInfo.SetPosition(aAx3);
|
aInfo.SetPosition(aAx3);
|
||||||
//aInfo.SetRadius1(aR1);
|
//aInfo.SetRadius1(aR1);
|
||||||
//
|
//
|
||||||
if (aNbWires>1) return;
|
if (aNbWires>1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
|
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
|
||||||
bInfU1=Precision::IsNegativeInfinite(aUMin);
|
bInfU1=Precision::IsNegativeInfinite(aUMin);
|
||||||
@ -480,7 +476,9 @@ static
|
|||||||
aInfo.SetRadius1(aR1);
|
aInfo.SetRadius1(aR1);
|
||||||
aInfo.SetRadius2(aR2);
|
aInfo.SetRadius2(aR2);
|
||||||
//
|
//
|
||||||
if (aNbWires>1) return;
|
if (aNbWires>1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
|
aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
|
||||||
//
|
//
|
||||||
@ -491,7 +489,7 @@ static
|
|||||||
//function :FillEdge
|
//function :FillEdge
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void GEOMAlgo_ShapeInfoFiller::FillEdge(const TopoDS_Shape& aS)
|
void GEOMAlgo_ShapeInfoFiller::FillEdge(const TopoDS_Shape& aS)
|
||||||
{
|
{
|
||||||
myErrorStatus=0;
|
myErrorStatus=0;
|
||||||
//
|
//
|
||||||
@ -531,13 +529,54 @@ static
|
|||||||
aC3D=BRep_Tool::Curve(aE, aT1, aT2);
|
aC3D=BRep_Tool::Curve(aE, aT1, aT2);
|
||||||
GeomAdaptor_Curve aGAC(aC3D);
|
GeomAdaptor_Curve aGAC(aC3D);
|
||||||
aCT=aGAC.GetType();
|
aCT=aGAC.GetType();
|
||||||
bIsAllowedType=IsAllowedType(aCT);
|
bIsAllowedType=GEOMAlgo_ShapeInfoFiller::IsAllowedType(aCT);
|
||||||
if (!bIsAllowedType) {
|
if (!bIsAllowedType) {
|
||||||
FillSubShapes(aS);
|
FillSubShapes(aS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 10:19:03 2012f
|
||||||
|
// BSplineCurve
|
||||||
|
if (aCT==GeomAbs_BSplineCurve) {
|
||||||
|
Standard_Integer aNbKnots, aNbPoles, aDegree;
|
||||||
|
Standard_Real aLength;
|
||||||
|
gp_XYZ aXYZ1, aXYZ2, aXYZc;
|
||||||
|
Handle(Geom_BSplineCurve) aBSp;
|
||||||
|
//
|
||||||
|
aBSp=aGAC.BSpline();
|
||||||
|
aNbKnots=aBSp->NbKnots();
|
||||||
|
aNbPoles=aBSp->NbPoles();
|
||||||
|
aDegree =aBSp->Degree();
|
||||||
|
if (!(aDegree==1 && aNbKnots==2 && aNbPoles==2)) {
|
||||||
|
return; // unallowed B-Spline curve
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aInfo.SetKindOfShape(GEOMAlgo_KS_BSPLINE);
|
||||||
|
aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED);
|
||||||
|
//
|
||||||
|
aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED);
|
||||||
|
aInfo.SetKindOfName(GEOMAlgo_KN_SEGMENT);
|
||||||
|
aGAC.D0(aT1, aP1);
|
||||||
|
aGAC.D0(aT2, aP2);
|
||||||
|
aInfo.SetPnt1(aP1);
|
||||||
|
aInfo.SetPnt2(aP2);
|
||||||
|
//
|
||||||
|
aLength=aP1.Distance(aP2);
|
||||||
|
aInfo.SetLength(aLength);
|
||||||
|
//
|
||||||
|
aXYZ1=aP1.XYZ();
|
||||||
|
aXYZ2=aP2.XYZ();
|
||||||
|
aXYZc=aXYZ1+aXYZ2;
|
||||||
|
aXYZc.Multiply(0.5);
|
||||||
|
aPc.SetXYZ(aXYZc);
|
||||||
|
aInfo.SetLocation(aPc);
|
||||||
|
//
|
||||||
|
gp_Vec aVec(aPc, aP2);
|
||||||
|
gp_Dir aDir(aVec);
|
||||||
|
aInfo.SetDirection(aDir);
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 10:19:06 2012t
|
||||||
// Line
|
// Line
|
||||||
if (aCT==GeomAbs_Line) {
|
else if (aCT==GeomAbs_Line) {
|
||||||
Standard_Boolean bInf1, bInf2;
|
Standard_Boolean bInf1, bInf2;
|
||||||
Standard_Real aLength;
|
Standard_Real aLength;
|
||||||
gp_Lin aLin;
|
gp_Lin aLin;
|
||||||
@ -734,7 +773,7 @@ static
|
|||||||
//function :NbShells
|
//function :NbShells
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Integer NbShells(const TopoDS_Solid& aSd)
|
Standard_Integer GEOMAlgo_ShapeInfoFiller::NbShells(const TopoDS_Solid& aSd)
|
||||||
{
|
{
|
||||||
Standard_Integer iCnt;
|
Standard_Integer iCnt;
|
||||||
TopoDS_Iterator aIt;
|
TopoDS_Iterator aIt;
|
||||||
@ -742,7 +781,7 @@ Standard_Integer NbShells(const TopoDS_Solid& aSd)
|
|||||||
iCnt=0;
|
iCnt=0;
|
||||||
//
|
//
|
||||||
aIt.Initialize(aSd);
|
aIt.Initialize(aSd);
|
||||||
for (; aIt.More(); aIt.Next()){
|
for (; aIt.More(); aIt.Next()) {
|
||||||
//const TopoDS_Shape& aSh=aIt.Value();
|
//const TopoDS_Shape& aSh=aIt.Value();
|
||||||
++iCnt;
|
++iCnt;
|
||||||
}
|
}
|
||||||
@ -752,7 +791,7 @@ Standard_Integer NbShells(const TopoDS_Solid& aSd)
|
|||||||
//function : NbWires
|
//function : NbWires
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Integer NbWires(const TopoDS_Face& aF)
|
Standard_Integer GEOMAlgo_ShapeInfoFiller::NbWires(const TopoDS_Face& aF)
|
||||||
{
|
{
|
||||||
Standard_Integer iCnt;
|
Standard_Integer iCnt;
|
||||||
TopoDS_Iterator aIt;
|
TopoDS_Iterator aIt;
|
||||||
@ -760,7 +799,7 @@ Standard_Integer NbWires(const TopoDS_Face& aF)
|
|||||||
iCnt=0;
|
iCnt=0;
|
||||||
//
|
//
|
||||||
aIt.Initialize(aF);
|
aIt.Initialize(aF);
|
||||||
for (; aIt.More(); aIt.Next()){
|
for (; aIt.More(); aIt.Next()) {
|
||||||
//const TopoDS_Shape& aW=aIt.Value();
|
//const TopoDS_Shape& aW=aIt.Value();
|
||||||
++iCnt;
|
++iCnt;
|
||||||
}
|
}
|
||||||
@ -770,12 +809,15 @@ Standard_Integer NbWires(const TopoDS_Face& aF)
|
|||||||
//function : IsAllowedType
|
//function : IsAllowedType
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Boolean IsAllowedType(const GeomAbs_CurveType aCT)
|
Standard_Boolean GEOMAlgo_ShapeInfoFiller::IsAllowedType(const GeomAbs_CurveType aCT)
|
||||||
{
|
{
|
||||||
Standard_Boolean bRet;
|
Standard_Boolean bRet;
|
||||||
Standard_Integer i, aNb;
|
Standard_Integer i, aNb;
|
||||||
GeomAbs_CurveType aTypes[]={
|
GeomAbs_CurveType aTypes[]={
|
||||||
GeomAbs_Line, GeomAbs_Circle, GeomAbs_Ellipse
|
GeomAbs_Line,
|
||||||
|
GeomAbs_Circle,
|
||||||
|
GeomAbs_Ellipse,
|
||||||
|
GeomAbs_BSplineCurve //modified by NIZNHY-PKV Tue Jul 03 10:18:01 2012ft
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
bRet=Standard_False;
|
bRet=Standard_False;
|
||||||
@ -783,14 +825,13 @@ Standard_Boolean IsAllowedType(const GeomAbs_CurveType aCT)
|
|||||||
for (i=0; i<aNb && !bRet; ++i) {
|
for (i=0; i<aNb && !bRet; ++i) {
|
||||||
bRet=(aCT==aTypes[i]);
|
bRet=(aCT==aTypes[i]);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : IsAllowedType
|
//function : IsAllowedType
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Boolean IsAllowedType(const GeomAbs_SurfaceType aST)
|
Standard_Boolean GEOMAlgo_ShapeInfoFiller::IsAllowedType(const GeomAbs_SurfaceType aST)
|
||||||
{
|
{
|
||||||
Standard_Boolean bRet;
|
Standard_Boolean bRet;
|
||||||
Standard_Integer i, aNb;
|
Standard_Integer i, aNb;
|
||||||
|
@ -15,24 +15,30 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
//
|
//
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
|
||||||
#ifndef _GEOMAlgo_ShapeInfoFiller_HeaderFile
|
#ifndef _GEOMAlgo_ShapeInfoFiller_HeaderFile
|
||||||
#define _GEOMAlgo_ShapeInfoFiller_HeaderFile
|
#define _GEOMAlgo_ShapeInfoFiller_HeaderFile
|
||||||
|
|
||||||
#include <Standard.hxx>
|
#include <Standard.hxx>
|
||||||
#include <Standard_Macro.hxx>
|
#include <Standard_Macro.hxx>
|
||||||
#include <TopoDS_Shape.hxx>
|
|
||||||
#include <GEOMAlgo_ShapeInfo.hxx>
|
|
||||||
#include <GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx>
|
|
||||||
#include <Standard_Real.hxx>
|
#include <Standard_Real.hxx>
|
||||||
#include <GEOMAlgo_Algo.hxx>
|
|
||||||
#include <TopoDS_Face.hxx>
|
|
||||||
#include <gp_Pln.hxx>
|
#include <gp_Pln.hxx>
|
||||||
#include <gp_Sphere.hxx>
|
#include <gp_Sphere.hxx>
|
||||||
#include <gp_Cylinder.hxx>
|
#include <gp_Cylinder.hxx>
|
||||||
#include <gp_Cone.hxx>
|
#include <gp_Cone.hxx>
|
||||||
#include <gp_Torus.hxx>
|
#include <gp_Torus.hxx>
|
||||||
|
|
||||||
|
#include <GeomAbs_CurveType.hxx>
|
||||||
|
#include <GeomAbs_SurfaceType.hxx>
|
||||||
|
|
||||||
#include <TopoDS_Solid.hxx>
|
#include <TopoDS_Solid.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
|
||||||
|
#include <GEOMAlgo_ShapeInfo.hxx>
|
||||||
|
#include <GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx>
|
||||||
|
#include <GEOMAlgo_Algo.hxx>
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//class : GEOMAlgo_ShapeInfoFiller
|
//class : GEOMAlgo_ShapeInfoFiller
|
||||||
@ -114,10 +120,27 @@ class GEOMAlgo_ShapeInfoFiller : public GEOMAlgo_Algo
|
|||||||
Standard_EXPORT
|
Standard_EXPORT
|
||||||
void FillDetails(const TopoDS_Solid& aS) ;
|
void FillDetails(const TopoDS_Solid& aS) ;
|
||||||
|
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 13:31:43 2012f
|
||||||
|
Standard_EXPORT
|
||||||
|
Standard_Boolean TreatStepSphere(const TopoDS_Solid& aS);
|
||||||
|
|
||||||
|
Standard_EXPORT static
|
||||||
|
Standard_Boolean IsAllowedType(const GeomAbs_CurveType aCT);
|
||||||
|
|
||||||
|
Standard_EXPORT static
|
||||||
|
Standard_Boolean IsAllowedType(const GeomAbs_SurfaceType aST);
|
||||||
|
|
||||||
|
Standard_EXPORT static
|
||||||
|
Standard_Integer NbWires(const TopoDS_Face& aF);
|
||||||
|
|
||||||
|
Standard_EXPORT static
|
||||||
|
Standard_Integer NbShells(const TopoDS_Solid& aS);
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 13:31:49 2012t
|
||||||
|
|
||||||
TopoDS_Shape myShape;
|
TopoDS_Shape myShape;
|
||||||
GEOMAlgo_ShapeInfo myEmptyInfo;
|
GEOMAlgo_ShapeInfo myEmptyInfo;
|
||||||
GEOMAlgo_IndexedDataMapOfShapeShapeInfo myMapInfo;
|
GEOMAlgo_IndexedDataMapOfShapeShapeInfo myMapInfo;
|
||||||
Standard_Real myTolerance;
|
Standard_Real myTolerance;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
//
|
//
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
|
||||||
|
|
||||||
#include <GEOMAlgo_ShapeInfoFiller.hxx>
|
#include <GEOMAlgo_ShapeInfoFiller.hxx>
|
||||||
|
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
|
#include <TColStd_MapOfInteger.hxx>
|
||||||
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
||||||
|
|
||||||
#include <gp_Lin.hxx>
|
#include <gp_Lin.hxx>
|
||||||
#include <gp_XYZ.hxx>
|
#include <gp_XYZ.hxx>
|
||||||
@ -31,6 +32,8 @@
|
|||||||
|
|
||||||
#include <ElCLib.hxx>
|
#include <ElCLib.hxx>
|
||||||
|
|
||||||
|
#include <GeomAdaptor_Surface.hxx>
|
||||||
|
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
#include <TopoDS_Vertex.hxx>
|
#include <TopoDS_Vertex.hxx>
|
||||||
#include <TopoDS_Edge.hxx>
|
#include <TopoDS_Edge.hxx>
|
||||||
@ -45,18 +48,25 @@
|
|||||||
|
|
||||||
#include <TopTools_MapOfShape.hxx>
|
#include <TopTools_MapOfShape.hxx>
|
||||||
#include <TopTools_IndexedMapOfShape.hxx>
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
|
||||||
#include <BRepTools_WireExplorer.hxx>
|
#include <BRepTools_WireExplorer.hxx>
|
||||||
|
#include <BRepGProp.hxx>
|
||||||
|
#include <GProp_GProps.hxx>
|
||||||
|
|
||||||
#include <GEOMAlgo_ShapeInfo.hxx>
|
#include <GEOMAlgo_ShapeInfo.hxx>
|
||||||
#include <TColStd_MapOfInteger.hxx>
|
|
||||||
#include <TColStd_IndexedMapOfInteger.hxx>
|
static
|
||||||
|
Standard_Boolean IsEqual(const gp_Sphere& aSp1,
|
||||||
|
const gp_Sphere& aSp2,
|
||||||
|
const Standard_Real aTolDst);
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : FillDetails
|
//function : FillDetails
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Solid& aSd)
|
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Solid& aSd)
|
||||||
{
|
{
|
||||||
|
Standard_Boolean bIsStepSphere;
|
||||||
Standard_Integer i, aNbF, aNbCyl, aNbCon, aNbPgn, aNbRct, aNbCrc, aNbX;
|
Standard_Integer i, aNbF, aNbCyl, aNbCon, aNbPgn, aNbRct, aNbCrc, aNbX;
|
||||||
TopoDS_Shape aFCyl, aFCon;
|
TopoDS_Shape aFCyl, aFCon;
|
||||||
TopTools_IndexedMapOfShape aMF;
|
TopTools_IndexedMapOfShape aMF;
|
||||||
@ -88,6 +98,15 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 13:23:55 2012f
|
||||||
|
else if (aNbF==2) {
|
||||||
|
// specific solid that should be treated as a sphere
|
||||||
|
bIsStepSphere=TreatStepSphere(aSd);
|
||||||
|
if (bIsStepSphere) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 13:23:57 2012t
|
||||||
//
|
//
|
||||||
aNbCyl=0;
|
aNbCyl=0;
|
||||||
aNbCon=0;
|
aNbCon=0;
|
||||||
@ -147,11 +166,9 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
//modified by NIZNHY-PKV Wed Jan 11 11:04:31 2012f
|
|
||||||
if (aNbF!=aNbPgn) {
|
if (aNbF!=aNbPgn) {
|
||||||
return;// -> GEOMAlgo_KN_UNKNOWN
|
return;// -> GEOMAlgo_KN_UNKNOWN
|
||||||
}
|
}
|
||||||
//modified by NIZNHY-PKV Wed Jan 11 11:04:37 2012t
|
|
||||||
if (aNbPgn!=6) {
|
if (aNbPgn!=6) {
|
||||||
aInfo.SetKindOfName(GEOMAlgo_KN_POLYHEDRON);
|
aInfo.SetKindOfName(GEOMAlgo_KN_POLYHEDRON);
|
||||||
return;
|
return;
|
||||||
@ -211,6 +228,11 @@
|
|||||||
const gp_Dir& aDNj=aIFj.Position().Direction();
|
const gp_Dir& aDNj=aIFj.Position().Direction();
|
||||||
//
|
//
|
||||||
aDot=aDNi*aDNj;
|
aDot=aDNi*aDNj;
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 10:01:56 2012f
|
||||||
|
if (aDot<0.) {
|
||||||
|
aDot=-aDot;
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 10:01:52 2012t
|
||||||
if (fabs(1.-aDot)<0.0001) {
|
if (fabs(1.-aDot)<0.0001) {
|
||||||
aMp.Add(i);
|
aMp.Add(i);
|
||||||
aMp.Add(j);
|
aMp.Add(j);
|
||||||
@ -269,7 +291,7 @@
|
|||||||
//function : FillDetails
|
//function : FillDetails
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
|
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
|
||||||
const gp_Pln& aPln)
|
const gp_Pln& aPln)
|
||||||
{
|
{
|
||||||
Standard_Integer aNbV, aNbE, i, j;
|
Standard_Integer aNbV, aNbE, i, j;
|
||||||
@ -456,7 +478,7 @@
|
|||||||
//function : FillDetails
|
//function : FillDetails
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
|
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
|
||||||
const gp_Sphere& )
|
const gp_Sphere& )
|
||||||
{
|
{
|
||||||
Standard_Integer aNbV, aNbE, aNbSE, aNbDE;
|
Standard_Integer aNbV, aNbE, aNbSE, aNbDE;
|
||||||
@ -506,7 +528,7 @@
|
|||||||
//function : FillDetails
|
//function : FillDetails
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
|
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
|
||||||
const gp_Cone& )//aCone)
|
const gp_Cone& )//aCone)
|
||||||
{
|
{
|
||||||
Standard_Integer aNbV, aNbE, aNbCE, aNbSE, aNbDE, i;
|
Standard_Integer aNbV, aNbE, aNbCE, aNbSE, aNbDE, i;
|
||||||
@ -635,7 +657,7 @@
|
|||||||
//function : FillDetails
|
//function : FillDetails
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
|
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
|
||||||
const gp_Cylinder& aCyl)
|
const gp_Cylinder& aCyl)
|
||||||
{
|
{
|
||||||
Standard_Integer i, aNbV, aNbE, aNbCE, aNbSE;
|
Standard_Integer i, aNbV, aNbE, aNbCE, aNbSE;
|
||||||
@ -720,7 +742,7 @@
|
|||||||
//function : FillDetails
|
//function : FillDetails
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
|
void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
|
||||||
const gp_Torus& )
|
const gp_Torus& )
|
||||||
{
|
{
|
||||||
Standard_Integer aNbV, aNbE, aNbSE;
|
Standard_Integer aNbV, aNbE, aNbSE;
|
||||||
@ -748,7 +770,6 @@
|
|||||||
for (; aExp.More(); aExp.Next()) {
|
for (; aExp.More(); aExp.Next()) {
|
||||||
aE=TopoDS::Edge(aExp.Current());
|
aE=TopoDS::Edge(aExp.Current());
|
||||||
if (aM.Add(aE)) {
|
if (aM.Add(aE)) {
|
||||||
//const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
|
|
||||||
if (BRep_Tool::IsClosed(aE, aF)) {
|
if (BRep_Tool::IsClosed(aE, aF)) {
|
||||||
++aNbSE;
|
++aNbSE;
|
||||||
}
|
}
|
||||||
@ -760,3 +781,121 @@
|
|||||||
}
|
}
|
||||||
aInfo.SetKindOfName(GEOMAlgo_KN_TORUS);
|
aInfo.SetKindOfName(GEOMAlgo_KN_TORUS);
|
||||||
}
|
}
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 13:29:41 2012f
|
||||||
|
//=======================================================================
|
||||||
|
//function : TreatStepSphere
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean
|
||||||
|
GEOMAlgo_ShapeInfoFiller::TreatStepSphere(const TopoDS_Solid& aSd)
|
||||||
|
{
|
||||||
|
Standard_Boolean bRet, bIsAllowedType, bOnlyClosed, bIsEqual;
|
||||||
|
Standard_Integer j;
|
||||||
|
Standard_Real aTolAng, aTolLin;
|
||||||
|
Standard_Real aVolume, aVolumeS, dV, aArea, aAreaS, dA;
|
||||||
|
gp_Sphere aSphere[2];
|
||||||
|
GeomAbs_SurfaceType aST;
|
||||||
|
Handle(Geom_Surface) aS;
|
||||||
|
GeomAdaptor_Surface aGAS;
|
||||||
|
TopExp_Explorer aExp;
|
||||||
|
//
|
||||||
|
bRet=Standard_False;
|
||||||
|
aTolLin=Precision::Confusion();
|
||||||
|
aTolAng=Precision::Angular();
|
||||||
|
//
|
||||||
|
aExp.Init(aSd, TopAbs_FACE);
|
||||||
|
for (j=0; aExp.More(); aExp.Next(), ++j) {
|
||||||
|
const TopoDS_Face& aF=*((TopoDS_Face*)&aExp.Current());
|
||||||
|
aS=BRep_Tool::Surface(aF);
|
||||||
|
aGAS.Load(aS);
|
||||||
|
aST=aGAS.GetType();
|
||||||
|
bIsAllowedType=GEOMAlgo_ShapeInfoFiller::IsAllowedType(aST);
|
||||||
|
if (!bIsAllowedType) {
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (aST!=GeomAbs_Sphere) {
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aSphere[j]=aGAS.Sphere();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
bIsEqual=IsEqual(aSphere[0], aSphere[1], aTolLin);
|
||||||
|
if (!bIsEqual) {
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//--------------------------------
|
||||||
|
GProp_GProps aGProps;
|
||||||
|
//
|
||||||
|
bOnlyClosed=Standard_False;
|
||||||
|
//
|
||||||
|
aVolume=aSphere[0].Volume();
|
||||||
|
//
|
||||||
|
BRepGProp::VolumeProperties(aSd, aGProps, bOnlyClosed);
|
||||||
|
aVolumeS=aGProps.Mass();
|
||||||
|
if (aVolumeS<0.) {
|
||||||
|
aVolumeS=-aVolumeS;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
dV=fabs(aVolumeS-aVolume);
|
||||||
|
if (dV>aTolLin) {
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//--------------------------------
|
||||||
|
aArea=aSphere[0].Area();
|
||||||
|
//
|
||||||
|
BRepGProp::SurfaceProperties(aSd, aGProps);
|
||||||
|
aAreaS=aGProps.Mass();
|
||||||
|
//
|
||||||
|
dA=fabs(aAreaS-aArea);
|
||||||
|
if (dA>aTolLin) {
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//--------------------------------
|
||||||
|
gp_Pnt aP0;
|
||||||
|
gp_Ax3 aAx3;
|
||||||
|
Standard_Real aR1;
|
||||||
|
//
|
||||||
|
aP0=aSphere[0].Location();
|
||||||
|
aAx3=aSphere[0].Position();
|
||||||
|
aR1=aSphere[0].Radius();
|
||||||
|
//
|
||||||
|
GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aSd);
|
||||||
|
//
|
||||||
|
aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
|
||||||
|
aInfo.SetLocation(aP0);
|
||||||
|
aInfo.SetPosition(aAx3);
|
||||||
|
aInfo.SetRadius1(aR1);
|
||||||
|
//
|
||||||
|
return !bRet;// true
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : IsEqual
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean IsEqual(const gp_Sphere& aSp1,
|
||||||
|
const gp_Sphere& aSp2,
|
||||||
|
const Standard_Real aTolLin)
|
||||||
|
{
|
||||||
|
Standard_Boolean bRet;
|
||||||
|
Standard_Real aR1, aR2, aD2;
|
||||||
|
//
|
||||||
|
bRet=Standard_False;
|
||||||
|
aR1=aSp1.Radius();
|
||||||
|
aR2=aSp2.Radius();
|
||||||
|
if (fabs(aR1-aR2)>aTolLin) {
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
const gp_Pnt& aPC1=aSp1.Position().Location();
|
||||||
|
const gp_Pnt& aPC2=aSp2.Position().Location();
|
||||||
|
//
|
||||||
|
aD2=aPC1.SquareDistance(aPC2);
|
||||||
|
bRet=(aD2<aTolLin*aTolLin);
|
||||||
|
//
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
//modified by NIZNHY-PKV Tue Jul 03 13:29:43 2012t
|
||||||
|
Loading…
x
Reference in New Issue
Block a user