mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-27 22:30:32 +05:00
0021538: EDF GEOM: GetShapesOnShapeAsCompound fails on cylinders for some cases
This commit is contained in:
parent
b10aa2d603
commit
dfc4b8a3e1
@ -78,6 +78,19 @@
|
||||
#include <GEOMAlgo_PassKey.hxx>
|
||||
#include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>
|
||||
#include <GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx>
|
||||
//
|
||||
#include <gp_Dir2d.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
#include <Geom2dHatch_Hatcher.hxx>
|
||||
#include <TColStd_ListOfInteger.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <HatchGen_Domain.hxx>
|
||||
#include <Geom2dHatch_Hatcher.hxx>
|
||||
#include <IntTools_Context.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <IntTools_Tools.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : GEOMAlgo_FinderShapeOn1
|
||||
@ -595,8 +608,6 @@
|
||||
void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Face& aF,
|
||||
GEOMAlgo_ListOfPnt& aLP)
|
||||
{
|
||||
myErrorStatus=0;
|
||||
//
|
||||
Standard_Integer j, j1, j2, k, n[4], aNbLinks, aNx, aNb, iCnt;//, aNbMax, *pIds;
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aTRF;
|
||||
@ -605,6 +616,8 @@
|
||||
GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger aIt;
|
||||
gp_Pnt aP, aP1, aP2;
|
||||
//
|
||||
myErrorStatus=0;
|
||||
//
|
||||
aLP.Clear();
|
||||
//
|
||||
aTRF=BRep_Tool::Triangulation(aF, aLoc);
|
||||
@ -648,20 +661,11 @@
|
||||
iCnt=aIt.Value();
|
||||
if (iCnt==1) {
|
||||
const GEOMAlgo_PassKey& aPK=aIt.Key();
|
||||
//qf
|
||||
/*
|
||||
aNbMax=aPK.NbMax();
|
||||
pIds=(Standard_Integer*)aPK.Key();
|
||||
for (k=1; k<3; ++k) {
|
||||
aNx=*(pIds+aNbMax-k);
|
||||
aMBN.Add(aNx);
|
||||
}
|
||||
*/
|
||||
aNx=(Standard_Integer)aPK.Id(1);
|
||||
aMBN.Add(aNx);
|
||||
aNx=(Standard_Integer)aPK.Id(2);
|
||||
aMBN.Add(aNx);
|
||||
//qt
|
||||
|
||||
}
|
||||
}
|
||||
//
|
||||
@ -677,67 +681,69 @@
|
||||
//
|
||||
aNb=aLP.Extent();
|
||||
//
|
||||
if (!aNb && myNbPntsMin) {
|
||||
// try to fill it yourself
|
||||
Standard_Boolean bIsDone;
|
||||
Standard_Integer aN1, aN2;
|
||||
//modified by NIZNHY-PKV Mon Sep 24 08:42:32 2012f
|
||||
if (!aNb && myNbPntsMin) { // A
|
||||
Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint;
|
||||
Standard_Integer i, aNb, aIx, iErr, aNbDomains;
|
||||
Standard_Real aUMin, aUMax, aVMin, aVMax, dU, aUx, aVx, aV1, aV2;
|
||||
gp_Pnt aPx;
|
||||
gp_Dir2d aD2D (0., 1.);
|
||||
gp_Pnt2d aP2D;
|
||||
Handle(Geom2d_Line) aL2D;
|
||||
Handle(Geom_Surface) aS;
|
||||
GeomAdaptor_Surface aGAS;
|
||||
GeomAbs_SurfaceType aType;
|
||||
TopoDS_Face aFF;
|
||||
//
|
||||
aS=BRep_Tool::Surface(aF);
|
||||
aGAS.Load(aS);
|
||||
aType=aGAS.GetType();
|
||||
if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) {
|
||||
// inner links
|
||||
aNbLinks=aMPKI.Extent();
|
||||
aIt.Initialize(aMPKI);
|
||||
for (; aIt.More(); aIt.Next()) {
|
||||
iCnt=aIt.Value();
|
||||
if (iCnt>1) {
|
||||
// take the first having occured inner link
|
||||
// and discretize it
|
||||
const GEOMAlgo_PassKey& aPK=aIt.Key();
|
||||
//qf
|
||||
/*
|
||||
aNbMax=aPK.NbMax();
|
||||
pIds=(Standard_Integer*)aPK.Key();
|
||||
aN1=*(pIds+aNbMax-1);
|
||||
aN2=*(pIds+aNbMax-2);
|
||||
*/
|
||||
aFF=aF;
|
||||
aFF.Orientation (TopAbs_FORWARD);
|
||||
//
|
||||
aN1=(Standard_Integer)aPK.Id(1);
|
||||
aN2=(Standard_Integer)aPK.Id(2);
|
||||
//qt
|
||||
aP1=aNodes(aN1).Transformed(aTrsf);
|
||||
aP2=aNodes(aN2).Transformed(aTrsf);
|
||||
Geom2dHatch_Hatcher& aHatcher=myContext->Hatcher(aFF);
|
||||
//
|
||||
if (aType==GeomAbs_Cylinder) {
|
||||
Standard_Real aTolSM;
|
||||
gp_Cylinder aCyl;
|
||||
aS=BRep_Tool::Surface(aFF);
|
||||
BRepTools::UVBounds(aFF, aUMin, aUMax, aVMin, aVMax);
|
||||
//
|
||||
aTolSM=1.523e-6;//~1.-cos(0.1 deg)
|
||||
aCyl=aGAS.Cylinder();
|
||||
if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, aTolSM)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
aNb=myNbPntsMin+1;
|
||||
dU=(aUMax-aUMin)/aNb;
|
||||
for (i=1; i<aNb; ++i) {
|
||||
aUx=aUMin+i*dU;
|
||||
aP2D.SetCoord(aUx, 0.);
|
||||
aL2D=new Geom2d_Line (aP2D, aD2D);
|
||||
Geom2dAdaptor_Curve aHCur(aL2D);
|
||||
//
|
||||
BRepLib_MakeEdge aBME(aP1, aP2);
|
||||
bIsDone=aBME.IsDone();
|
||||
aHatcher.ClrHatchings();
|
||||
aIx=aHatcher.AddHatching(aHCur);
|
||||
//
|
||||
aHatcher.Trim(aIx);
|
||||
bIsDone=aHatcher.TrimDone(aIx);
|
||||
if (!bIsDone) {
|
||||
myErrorStatus=30; //can not obtain the line fron the link
|
||||
myErrorStatus=42;
|
||||
return;
|
||||
}
|
||||
//
|
||||
const TopoDS_Shape& aSx=aBME.Shape();
|
||||
const TopoDS_Edge& aE=TopoDS::Edge(aSx);
|
||||
aHatcher.ComputeDomains(aIx);
|
||||
bIsDone=aHatcher.IsDone(aIx);
|
||||
if (!bIsDone) {
|
||||
continue;
|
||||
}
|
||||
//
|
||||
InnerPoints(aE, myNbPntsMin, aLP);
|
||||
aNbDomains=aHatcher.NbDomains(aIx);
|
||||
for (j=1; j<=aNbDomains; ++j) {
|
||||
const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, j) ;
|
||||
// 1
|
||||
bHasFirstPoint=aDomain.HasFirstPoint();
|
||||
bHasSecondPoint=aDomain.HasSecondPoint();
|
||||
if (!bHasFirstPoint || !bHasSecondPoint) {
|
||||
continue;
|
||||
}
|
||||
// 2
|
||||
aV1=aDomain.FirstPoint().Parameter();
|
||||
aV2=aDomain.SecondPoint().Parameter();
|
||||
aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
|
||||
// 3
|
||||
aS->D0(aUx, aVx, aPx);
|
||||
aLP.Append(aPx);
|
||||
break;
|
||||
}// if (iCnt>1)
|
||||
}// for (; aIt.More(); aIt.Next())
|
||||
}// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder)
|
||||
}
|
||||
}// for (i=1; i<aNb; ++i) {
|
||||
}// if (!aNb && myNbPntsMin) {
|
||||
}
|
||||
//=======================================================================
|
||||
@ -843,3 +849,63 @@
|
||||
// 30- can not obtain the line from the link
|
||||
// 40- point can not be classified
|
||||
// 41- invalid data for classifier
|
||||
// 42- can not compute hatching
|
||||
|
||||
/*
|
||||
// A
|
||||
if (!aNb && myNbPntsMin) {
|
||||
// try to fill it yourself
|
||||
Standard_Boolean bIsDone;
|
||||
Standard_Integer aN1, aN2;
|
||||
Handle(Geom_Surface) aS;
|
||||
GeomAdaptor_Surface aGAS;
|
||||
GeomAbs_SurfaceType aType;
|
||||
//
|
||||
aS=BRep_Tool::Surface(aF);
|
||||
aGAS.Load(aS);
|
||||
aType=aGAS.GetType();
|
||||
if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) {
|
||||
// inner links
|
||||
aNbLinks=aMPKI.Extent();
|
||||
aIt.Initialize(aMPKI);
|
||||
for (; aIt.More(); aIt.Next()) {
|
||||
iCnt=aIt.Value();
|
||||
if (iCnt>1) {
|
||||
// take the first having occured inner link
|
||||
// and discretize it
|
||||
const GEOMAlgo_PassKey& aPK=aIt.Key();
|
||||
//
|
||||
aN1=(Standard_Integer)aPK.Id(1);
|
||||
aN2=(Standard_Integer)aPK.Id(2);
|
||||
//
|
||||
aP1=aNodes(aN1).Transformed(aTrsf);
|
||||
aP2=aNodes(aN2).Transformed(aTrsf);
|
||||
//
|
||||
if (aType==GeomAbs_Cylinder) {
|
||||
Standard_Real aTolSM;
|
||||
gp_Cylinder aCyl;
|
||||
//
|
||||
aTolSM=1.523e-6;//~1.-cos(0.1 deg)
|
||||
aCyl=aGAS.Cylinder();
|
||||
if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, aTolSM)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//
|
||||
BRepLib_MakeEdge aBME(aP1, aP2);
|
||||
bIsDone=aBME.IsDone();
|
||||
if (!bIsDone) {
|
||||
myErrorStatus=30; //can not obtain the line fron the link
|
||||
return;
|
||||
}
|
||||
//
|
||||
const TopoDS_Shape& aSx=aBME.Shape();
|
||||
const TopoDS_Edge& aE=TopoDS::Edge(aSx);
|
||||
//
|
||||
InnerPoints(aE, myNbPntsMin, aLP);
|
||||
break;
|
||||
}// if (iCnt>1)
|
||||
}// for (; aIt.More(); aIt.Next())
|
||||
}// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder)
|
||||
}// if (!aNb && myNbPntsMin) {
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user