mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
HLR debug
This commit is contained in:
@@ -1239,14 +1239,15 @@ void ComputeInternalPoints
|
||||
solution = Standard_False;
|
||||
math_Vector dir1(1,2), dir2(1,2);
|
||||
math_Vector prevX(1,2), prevPrevX (1,2);
|
||||
int count = 0;
|
||||
int revCount = 0;
|
||||
double dot = 0;
|
||||
double t = 0.5;
|
||||
Standard_Integer count = 0;
|
||||
Standard_Integer revCount = 0;
|
||||
Standard_Integer maxRevCount = 10000;
|
||||
Standard_Real dot = 0;
|
||||
Standard_Real t = 0.5;
|
||||
while (!solution)
|
||||
{
|
||||
X(1) =/* (XInf(1) + XSup(1)) /2.;*/ XInf(1) + t * (XSup(1) - XInf(1));
|
||||
X(2) = /*(XInf(2) + XSup(2)) /2.;*/XInf(2) + t * (XSup(2) - XInf(2));
|
||||
X(1) = XInf(1) + t * (XSup(1) - XInf(1));
|
||||
X(2) = XInf(2) + t * (XSup(2) - XInf(2));
|
||||
rsnld.Perform(SFunc,X,infb,supb);
|
||||
|
||||
if (!rsnld.IsDone()) {
|
||||
@@ -1304,13 +1305,11 @@ void ComputeInternalPoints
|
||||
else if (vtestb.Dot(vecref) < 0.) {
|
||||
XSup = X;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
XInf = X;
|
||||
if (revCount > 10000)
|
||||
{
|
||||
//XInf = (X + prevPrevX)/2;
|
||||
if (revCount > maxRevCount)
|
||||
t = 0.75;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // on n est pas sur une solution
|
||||
|
@@ -63,6 +63,29 @@ void HLRAppli_ReflectLines::SetAxes(const Standard_Real Nx,
|
||||
myProjector = HLRAlgo_Projector(T,IsPerspective,aFocus);
|
||||
}
|
||||
|
||||
void HLRAppli_ReflectLines::SetAxes(const Standard_Real Nx,
|
||||
const Standard_Real Ny,
|
||||
const Standard_Real Nz,
|
||||
const Standard_Real XAt,
|
||||
const Standard_Real YAt,
|
||||
const Standard_Real ZAt,
|
||||
const Standard_Real XUp,
|
||||
const Standard_Real YUp,
|
||||
const Standard_Real ZUp,
|
||||
Standard_Boolean IsPerspective,
|
||||
Standard_Real theFocus)
|
||||
{
|
||||
gp_Pnt At (XAt,YAt,ZAt);
|
||||
gp_Dir Zpers (Nx,Ny,Nz);
|
||||
gp_Dir Ypers (XUp,YUp,ZUp);
|
||||
gp_Dir Xpers = Ypers.Crossed(Zpers);
|
||||
gp_Ax3 Axe (At, Zpers, Xpers);
|
||||
gp_Trsf T;
|
||||
T.SetTransformation(Axe);
|
||||
myProjector = HLRAlgo_Projector(T,IsPerspective,theFocus);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
@@ -117,8 +140,9 @@ TopoDS_Shape HLRAppli_ReflectLines::GetResult() const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TopoDS_Shape HLRAppli_ReflectLines::GetCompoundOfFaces(bool theMode,
|
||||
TopTools_DataMapOfShapeShape& OrigFaceToProjFace ) const
|
||||
TopTools_DataMapOfShapeShape& OrigFaceToProjFace,
|
||||
TopTools_DataMapOfShapeShape& ProjFaceToOrigFace) const
|
||||
{
|
||||
HLRBRep_HLRToShape aHLRToShape( myHLRAlgo );
|
||||
return aHLRToShape.CompoundOfFaces(theMode, OrigFaceToProjFace);
|
||||
return aHLRToShape.CompoundOfFaces(theMode, OrigFaceToProjFace, ProjFaceToOrigFace);
|
||||
}
|
||||
|
@@ -48,6 +48,13 @@ public:
|
||||
//! the coordinates of the vertical direction vector.
|
||||
Standard_EXPORT void SetAxes (const Standard_Real Nx, const Standard_Real Ny, const Standard_Real Nz, const Standard_Real XAt, const Standard_Real YAt, const Standard_Real ZAt, const Standard_Real XUp, const Standard_Real YUp, const Standard_Real ZUp);
|
||||
|
||||
|
||||
Standard_EXPORT void SetAxes (const Standard_Real Nx, const Standard_Real Ny, const Standard_Real Nz,
|
||||
const Standard_Real XAt, const Standard_Real YAt, const Standard_Real ZAt,
|
||||
const Standard_Real XUp, const Standard_Real YUp, const Standard_Real ZUp,
|
||||
Standard_Boolean IsPerspective, Standard_Real theFocus);
|
||||
|
||||
|
||||
Standard_EXPORT void Perform();
|
||||
|
||||
//! returns resulting compound of reflect lines
|
||||
@@ -62,7 +69,8 @@ public:
|
||||
const Standard_Boolean In3d) const;
|
||||
|
||||
Standard_EXPORT TopoDS_Shape GetCompoundOfFaces(bool theMode,
|
||||
TopTools_DataMapOfShapeShape& OrigFaceToProjFace) const;
|
||||
TopTools_DataMapOfShapeShape& OrigFaceToProjFace,
|
||||
TopTools_DataMapOfShapeShape& ProjFaceToOrigFace) const;
|
||||
|
||||
|
||||
|
||||
|
@@ -569,7 +569,6 @@ public:
|
||||
myStop = 1;
|
||||
}
|
||||
return Standard_True;
|
||||
//int nbpnt = an_inter->.NbPnt();
|
||||
}
|
||||
|
||||
void SetLine (const gp_Lin& theLine)
|
||||
@@ -623,8 +622,7 @@ static bool FuseVE(TopoDS_Shape& theRes)
|
||||
}
|
||||
|
||||
static void ProcessHVertices(TopoDS_Shape& theRes,
|
||||
NCollection_IndexedDataMap<TopoDS_Edge, BRepAdaptor_Curve2d, TopTools_ShapeMapHasher>& theEdAd,
|
||||
NCollection_DataMap<TopoDS_Edge, Bnd_Box2d, TopTools_ShapeMapHasher>& theEdBnd2d )
|
||||
NCollection_IndexedDataMap<TopoDS_Edge, BRepAdaptor_Curve2d, TopTools_ShapeMapHasher>& theEdAd)
|
||||
{
|
||||
BRepTools_ReShape reshaper;
|
||||
///hanging vertices => find closely located point on some edge or vertex
|
||||
@@ -661,22 +659,19 @@ static void ProcessHVertices(TopoDS_Shape& theRes,
|
||||
NCollection_UBTree <Standard_Integer, Bnd_Box2d> aTreeVE;
|
||||
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box2d> aTreeFillerVE (aTreeVE);
|
||||
int nbEE = EE.Extent();
|
||||
//NCollection_Array1<BRepAdaptor_Curve2d> anEdgeAdapters(1, nbEE);
|
||||
for (Standard_Integer i = 1; i <= nbEE; i++)
|
||||
{
|
||||
const TopoDS_Edge& anE = TopoDS::Edge(EE(i));
|
||||
Bnd_Box2d aBB;
|
||||
theEdAd.Add(anE, BRepAdaptor_Curve2d(anE, aDraftPrFace));
|
||||
BndLib_Add2dCurve::Add(*theEdAd.Seek(anE), 0, aBB);
|
||||
theEdBnd2d.Bind(anE, aBB);
|
||||
aTreeFillerVE.Add(i, aBB);
|
||||
}
|
||||
|
||||
aTreeFillerVE.Fill();
|
||||
HLRVE_BndBoxTreeSelector aSelectorVE(theEdAd, Precision::Infinite()); //min dist doesn't matter here
|
||||
HLRVE_BndBoxTreeSelector aSelectorVE(theEdAd, Precision::Infinite()); //min dist doesn't matter here
|
||||
//
|
||||
|
||||
TopTools_IndexedMapOfShape toadd, torem;//temp
|
||||
TopTools_IndexedMapOfShape toadd, torem;
|
||||
for (int i = 1; i <= HV.Extent(); i++ )
|
||||
{
|
||||
const TopoDS_Vertex& CHV = TopoDS::Vertex(HV(i));
|
||||
@@ -685,20 +680,19 @@ static void ProcessHVertices(TopoDS_Shape& theRes,
|
||||
int id = VV.FindIndex(CHV);
|
||||
aSelectorVV.Reset(Precision::Infinite());
|
||||
aSelectorVV.SetCurrentPoint( id );
|
||||
/*int resVV =*/ aTreeVV.Select(aSelectorVV);
|
||||
aTreeVV.Select(aSelectorVV);
|
||||
double aMinDDistReached = aSelectorVV.GetMinDDist();
|
||||
TopoDS_Vertex aResV = TopoDS::Vertex(VV(aSelectorVV.GetResVId()));
|
||||
//
|
||||
aSelectorVE.Reset(aMinDDistReached);
|
||||
aSelectorVE.SetCurrentPoint( CHVPnt );
|
||||
/*int resVE = */aTreeVE.Select(aSelectorVE);
|
||||
|
||||
aTreeVE.Select(aSelectorVE);
|
||||
//
|
||||
Extrema_POnCurv2d aPSolRes;
|
||||
BRepAdaptor_Curve2d aResEA;
|
||||
bool VEFound = aSelectorVE.GetPResult(aPSolRes, aResEA);
|
||||
if (VEFound)
|
||||
{
|
||||
///if (BRep_Tool::Degenerated(E)) //can be degenerted??
|
||||
double aPar = aPSolRes.Parameter();
|
||||
const TopoDS_Edge& aResE = aResEA.Edge();
|
||||
TopoDS_Edge aDE1 = TopoDS::Edge(aResE.EmptyCopied().Oriented(TopAbs_FORWARD));
|
||||
@@ -718,19 +712,29 @@ static void ProcessHVertices(TopoDS_Shape& theRes,
|
||||
gp_Pnt aNC;
|
||||
double aNTol;
|
||||
BRepLib::BoundingVertex(nls, aNC, aNTol);
|
||||
|
||||
gp_Pnt aFVP = BRep_Tool::Pnt(aFV);
|
||||
gp_Pnt aLVP = BRep_Tool::Pnt(aLV);
|
||||
if (aFVP.Distance(aNC) < aNTol*1e10 ||
|
||||
aLVP.Distance(aNC) < aNTol*1e10)
|
||||
double dF_NC = aFVP.Distance(aNC);
|
||||
double dL_NC = aLVP.Distance(aNC);
|
||||
double aFVTol = BRep_Tool::Tolerance(aFV);
|
||||
double aLVTol = BRep_Tool::Tolerance(aLV);
|
||||
bool aFt = (aNTol + aFVTol) > dF_NC;
|
||||
bool aLt = (aNTol + aLVTol) > dL_NC;
|
||||
|
||||
if (aFt || aLt)
|
||||
{
|
||||
nls.RemoveFirst();
|
||||
nls.Append(aResV);
|
||||
//either aFt or aLt is true; dont consider when both true => degenerated case
|
||||
TopoDS_Vertex maV;
|
||||
if (aFt)
|
||||
maV = TopoDS::Vertex(nls.Append(aFV));
|
||||
else
|
||||
maV = TopoDS::Vertex(nls.Append(aLV));
|
||||
BRepLib::BoundingVertex(nls, aNC, aNTol);
|
||||
BRep_Builder().UpdateVertex(aResV, aNC, aNTol);
|
||||
reshaper.Replace(CHV, aResV.Oriented(CHV.Orientation()));
|
||||
if (HV.Contains(aResV)) //if the closest vertex lays on edge => never contains in HV
|
||||
HV.RemoveKey(aResV);
|
||||
BRep_Builder().UpdateVertex(maV, aNC, aNTol);
|
||||
reshaper.Replace(CHV, maV.Oriented(CHV.Orientation()));
|
||||
if (HV.Contains(maV))
|
||||
HV.RemoveKey(maV);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -743,28 +747,11 @@ static void ProcessHVertices(TopoDS_Shape& theRes,
|
||||
BRep_Builder().Add(aDE2, CHV.Oriented(TopAbs_FORWARD));
|
||||
BRep_Builder().Add(aDE2, aLV.Oriented(TopAbs_REVERSED));
|
||||
//
|
||||
|
||||
///TODO temp
|
||||
torem.Add(aResE);
|
||||
toadd.Add(aDE1);
|
||||
toadd.Add(aDE2);
|
||||
//TopoDS_Compound aResCmp;
|
||||
//BRep_Builder().MakeCompound(aResCmp);
|
||||
//BRep_Builder().Add(aResCmp, aDE1);
|
||||
//BRep_Builder().Add(aResCmp, aDE2);
|
||||
//
|
||||
//TopoDS_Wire aResW;
|
||||
//BRep_Builder().MakeWire(aResW);
|
||||
//BRep_Builder().Add(aResW, aDE1);
|
||||
//BRep_Builder().Add(aResW, aDE2);
|
||||
//TopoDS_Wire aResW = BRepBuilderAPI_MakeWire(aDE1, aDE2).Wire(); //this will control proper sharing and tolerance matching between vertices
|
||||
/*{ //DEB
|
||||
TopTools_IndexedMapOfShape VVVV;
|
||||
TopExp::MapShapes(aResW, TopAbs_VERTEX, VVVV);
|
||||
//cout << VVVV.Extent() << endl;
|
||||
}*/
|
||||
//aResW.Orientation(aResE.Orientation());
|
||||
//reshape.Replace(aResE, aResCmp);
|
||||
TopoDS_Wire nW;
|
||||
BRep_Builder().MakeWire(nW);
|
||||
BRep_Builder().Add(nW, aDE1);
|
||||
BRep_Builder().Add(nW, aDE2);
|
||||
reshaper.Replace(aResE, nW);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -781,14 +768,7 @@ static void ProcessHVertices(TopoDS_Shape& theRes,
|
||||
HV.RemoveKey(aResV);
|
||||
}
|
||||
}
|
||||
//DEB
|
||||
for (int i =1; i<= torem.Extent() ;i++)
|
||||
BRep_Builder().Remove(theRes, torem(i));
|
||||
//DEB
|
||||
for (int i =1; i<= toadd.Extent() ;i++)
|
||||
BRep_Builder().Add(theRes, toadd(i));
|
||||
//
|
||||
theRes = reshaper.Apply(theRes); //replace only vertices
|
||||
theRes = reshaper.Apply(theRes);
|
||||
}
|
||||
|
||||
static void FillNode2LLMap(Standard_Integer NewNode, const Poly_MakeLoops2D::Link& NewLink,
|
||||
@@ -802,21 +782,26 @@ static void FillNode2LLMap(Standard_Integer NewNode, const Poly_MakeLoops2D::Lin
|
||||
|
||||
static TopAbs_State GetStateOfSamplePoint(const TopoDS_Face& ff2,
|
||||
const IntTools_FClass2d& fclass,
|
||||
const Bnd_Box2d& fbnd)
|
||||
const Bnd_Box& bb1,
|
||||
double mass1)
|
||||
{
|
||||
TopExp_Explorer exp(ff2, TopAbs_EDGE); //should contains at least one edge
|
||||
TopoDS_Edge fe2 = TopoDS::Edge(exp.Current());
|
||||
BRepAdaptor_Curve2d afe2(fe2, ff2);
|
||||
gp_Pnt2d middlepoint = afe2.Value((afe2.LastParameter() + afe2.FirstParameter()) / 2.0);
|
||||
Bnd_Box bb3d;
|
||||
BRepBndLib::Add(ff2, bb3d);
|
||||
Bnd_Box2d bb2d;
|
||||
bb2d.Set(gp_Pnt2d(bb3d.CornerMin().X(), bb3d.CornerMin().Y()));
|
||||
bb2d.Add(gp_Pnt2d(bb3d.CornerMax().X(), bb3d.CornerMax().Y()));
|
||||
if (bb2d.IsOut(middlepoint))
|
||||
return TopAbs_OUT;
|
||||
else
|
||||
return fclass.Perform(middlepoint);
|
||||
if (Abs(mass1)>1e-10) //?? toler
|
||||
{
|
||||
Bnd_Box2d bb2d;
|
||||
double xmin, ymin, zmin, xmax, ymax, zmax;
|
||||
bb1.Get(xmin, ymin, zmin, xmax, ymax, zmax);
|
||||
bb2d.Add(gp_Pnt2d(xmin, ymin));
|
||||
bb2d.Add(gp_Pnt2d(xmax, ymax));
|
||||
if (mass1 > 0 && bb2d.IsOut(middlepoint))
|
||||
return TopAbs_OUT;
|
||||
if (mass1 < 0 && bb2d.IsOut(middlepoint))
|
||||
return TopAbs_IN;
|
||||
}
|
||||
return fclass.Perform(middlepoint);
|
||||
}
|
||||
|
||||
bool HLRBRep_ParComp(const HLRFL_BndBoxTreeSelector::FaceParam& a,
|
||||
@@ -827,15 +812,14 @@ bool HLRBRep_ParComp(const HLRFL_BndBoxTreeSelector::FaceParam& a,
|
||||
|
||||
static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
NCollection_IndexedDataMap<TopoDS_Edge, BRepAdaptor_Curve2d, TopTools_ShapeMapHasher>& anEdAd,
|
||||
NCollection_DataMap<TopoDS_Edge, Bnd_Box2d, TopTools_ShapeMapHasher> theEdBnd2d,
|
||||
HLRAlgo_Projector& projector,
|
||||
const TopTools_ListOfShape& anOrigShapes,
|
||||
bool theMode,
|
||||
TopTools_DataMapOfShapeShape& OrigFaceToProjFace )
|
||||
TopTools_DataMapOfShapeShape& OrigFaceToProjFace,
|
||||
TopTools_DataMapOfShapeShape& ProjFaceToOrigFace)
|
||||
{
|
||||
NCollection_List<TopoDS_Wire> theLoops;
|
||||
NCollection_List<TopoDS_Wire> SelfLoops;
|
||||
NCollection_DataMap<TopoDS_Shape, Bnd_Box2d, TopTools_ShapeMapHasher> aShToBnd2d;
|
||||
TopoDS_Face aDraftPrFace;
|
||||
BRep_Builder().MakeFace(aDraftPrFace, BRepLib::Plane(), Precision::Confusion());
|
||||
TopTools_IndexedMapOfShape mN2V;
|
||||
@@ -860,9 +844,6 @@ static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
{
|
||||
const TopoDS_Wire& aW = BRepLib_MakeWire(E).Wire();
|
||||
SelfLoops.Append(aW);
|
||||
Bnd_Box2d aBB;
|
||||
BndLib_Add2dCurve::Add(BRepAdaptor_Curve2d(E, aDraftPrFace), 0, aBB);
|
||||
aShToBnd2d.Bind(aW, aBB);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -872,11 +853,7 @@ static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
{
|
||||
anEdAd.Add(E, BRepAdaptor_Curve2d(E, aDraftPrFace));
|
||||
anAd = anEdAd.Seek(E);
|
||||
Bnd_Box2d aBB;
|
||||
BndLib_Add2dCurve::Add(*anEdAd.Seek(E), 0, aBB);
|
||||
theEdBnd2d.Bind(E, aBB);
|
||||
}
|
||||
//NCollection_Handle<BRepAdaptor_Curve2d> adapt = new BRepAdaptor_Curve2d(E, aDraftPrFace);
|
||||
|
||||
gp_Pnt2d Pnt;
|
||||
gp_Vec2d Vec;
|
||||
@@ -949,40 +926,19 @@ static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
Info2->myD1L = D1L;
|
||||
}
|
||||
}
|
||||
|
||||
//DEBUG: print D1F
|
||||
/*{
|
||||
NCollection_DataMap<Standard_Integer, Poly_MakeLoops2D::ListOfLink>::Iterator it(mNode2ListOfLinks);
|
||||
for (;it.More();it.Next())
|
||||
{
|
||||
int nK = it.Key();
|
||||
Poly_MakeLoops2D::ListOfLink links = it.Value();
|
||||
Poly_MakeLoops2D::ListOfLink::Iterator itl(links);
|
||||
cout << "next:" << endl;
|
||||
for (;itl.More();itl.Next())
|
||||
{
|
||||
BRepFill_TangentLinkInfo linfo = mL2TI(itl.Value());
|
||||
cout << linfo.myD1F.X() << " " << linfo.myD1F.Y() << endl;
|
||||
TopoDS_Edge eee = mL2E(itl.Value());
|
||||
}
|
||||
}
|
||||
*/
|
||||
//
|
||||
BRepFill_PolyHelper helper(mL2TI, mNode2ListOfLinks);
|
||||
Poly_MakeLoops2D aLoopMaker(1, &helper, NCollection_BaseAllocator::CommonBaseAllocator() );
|
||||
for (NCollection_DataMap<Poly_MakeLoops2D::Link, TopoDS_Edge>::Iterator aMapIt (mL2E); aMapIt.More(); aMapIt.Next())
|
||||
aLoopMaker.AddLink(aMapIt.Key());
|
||||
|
||||
aLoopMaker.Perform(); //try to find loops
|
||||
aLoopMaker.Perform(); //try to find loopsEdBnd2d
|
||||
Standard_Integer NbLoops = aLoopMaker.GetNbLoops();
|
||||
Standard_Integer NbHangs = aLoopMaker.GetNbHanging();
|
||||
|
||||
cout << "NbLoops=" << NbLoops << endl;
|
||||
cout << "NbHangs=" << NbHangs << endl;
|
||||
|
||||
// if (NbLoops == 0 || NbHangs != 0 )
|
||||
// return Standard_False;
|
||||
|
||||
theLoops.Append(SelfLoops);
|
||||
for (Standard_Integer i = 1; i <= NbLoops; i++) //loops to wires
|
||||
{
|
||||
@@ -999,44 +955,20 @@ static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
E.Reverse();
|
||||
//if null => probably this edge was passed as two links (based on the same edge); so skip this edge
|
||||
if (!E.IsNull())
|
||||
{
|
||||
aWM.Add(E);
|
||||
aWBox2d.Add(theEdBnd2d(E));
|
||||
}
|
||||
}
|
||||
if (aWM.IsDone())
|
||||
{
|
||||
TopoDS_Wire W = aWM.Wire();
|
||||
if (W.Closed())
|
||||
{
|
||||
if (W.Closed())
|
||||
theLoops.Append(W);
|
||||
aShToBnd2d.Bind(W, aWBox2d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//DEBUG
|
||||
/* Poly_MakeLoops2D::ListOfLink theHLinks;
|
||||
aLoopMaker.GetHangingLinks(theHLinks);
|
||||
Poly_MakeLoops2D::ListOfLink::Iterator itt(theHLinks);
|
||||
|
||||
TopoDS_Compound cmpH;BRep_Builder().MakeCompound(cmpH);
|
||||
for (; itt.More();itt.Next())
|
||||
{
|
||||
Poly_MakeLoops2D::Link alink = itt.Value();
|
||||
const Poly_MakeLoops2D::Link& Link = itt.Value();
|
||||
TopoDS_Edge E = mL2E(Link);
|
||||
if (Link.flags & Poly_MakeLoops2D::LF_Reversed)
|
||||
E.Reverse();
|
||||
//if null => probably this edge was passed as two links (based on the same edge); so skip this edge
|
||||
if (!E.IsNull())
|
||||
BRep_Builder().Add(cmpH, E);
|
||||
}*/
|
||||
//
|
||||
|
||||
IntTools_Context context1;// = new IntTools_Context();
|
||||
NCollection_List<TopoDS_Wire>::Iterator itL(theLoops);
|
||||
NCollection_IndexedDataMap<TopoDS_Shape, double> lf1, lf2;
|
||||
NCollection_DataMap<TopoDS_Face, double> f2mass;
|
||||
for (; itL.More(); itL.Next())
|
||||
{
|
||||
const TopoDS_Wire& aW = itL.Value();
|
||||
@@ -1046,11 +978,10 @@ static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
BRep_Builder().MakeFace(ff, BRepLib::Plane(), Precision::Confusion());
|
||||
//plane is static; pcurves of edges are already based on this plane
|
||||
BRep_Builder().Add(ff, aW);
|
||||
aShToBnd2d(aW).Enlarge(0.001);
|
||||
aShToBnd2d.Bind(ff, aShToBnd2d(aW)); //bndbox still the same
|
||||
GProp_GProps pr;
|
||||
BRepGProp::SurfaceProperties(ff, pr);
|
||||
Standard_Real CurMass = pr.Mass();
|
||||
f2mass.Bind(ff, CurMass);
|
||||
if (Abs(CurMass) < 1e-10) //?? TODO
|
||||
continue;
|
||||
if (CurMass >= 0)
|
||||
@@ -1061,7 +992,6 @@ static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
NCollection_IndexedDataMap<TopoDS_Face, NCollection_List<TopoDS_Face>> FaceToIntWires;
|
||||
for (int i = 1; i <= lf1.Size() && !lf2.IsEmpty(); i++)
|
||||
{
|
||||
//NCollection_Handle<BRepTopAdaptor_FClass2d> fclass;
|
||||
NCollection_Sequence<TopoDS_Face> intf;
|
||||
const TopoDS_Face& ff1 = TopoDS::Face(lf1.FindKey(i));
|
||||
for (int j=1;j<= lf2.Size();j++)
|
||||
@@ -1071,11 +1001,10 @@ static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
if (pm < -nm)
|
||||
continue;
|
||||
const TopoDS_Face& ff2 = TopoDS::Face(lf2.FindKey(j));
|
||||
//if (!fclass)
|
||||
// fclass = new BRepTopAdaptor_FClass2d(ff1, Precision::Confusion());
|
||||
IntTools_FClass2d& fclass = context1.FClass2d(ff1);
|
||||
Bnd_Box2d fbnd = aShToBnd2d(ff1);
|
||||
TopAbs_State st = GetStateOfSamplePoint(ff2, fclass, fbnd);
|
||||
IntTools_FClass2d& fclass1 = context1.FClass2d(ff1);
|
||||
const Bnd_Box& bb1 = context1.BndBox(ff1);
|
||||
double mass1 = f2mass(ff1);
|
||||
TopAbs_State st = GetStateOfSamplePoint(ff2, fclass1, bb1, mass1);
|
||||
if (st == TopAbs_IN)
|
||||
intf.Append(ff2);
|
||||
}
|
||||
@@ -1084,16 +1013,17 @@ static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
{
|
||||
if (intfInd.Contains(i))
|
||||
continue;
|
||||
//BRepTopAdaptor_FClass2d fclassInt(intf(i), Precision::Confusion());
|
||||
IntTools_FClass2d& fclassInt = context1.FClass2d(intf(i));
|
||||
Bnd_Box2d fbndi = aShToBnd2d(intf(i));
|
||||
const TopoDS_Face& intfi = intf(i);
|
||||
IntTools_FClass2d& fclassInt = context1.FClass2d(intfi);
|
||||
const Bnd_Box& bb1 = context1.BndBox(intfi);
|
||||
double mass1 = f2mass(intfi);
|
||||
for (int j=1; j<= intf.Size();j++)
|
||||
{
|
||||
if (i==j)
|
||||
continue;
|
||||
if (intfInd.Contains(j))
|
||||
continue;
|
||||
TopAbs_State st = GetStateOfSamplePoint(intf(j), fclassInt, fbndi);
|
||||
TopAbs_State st = GetStateOfSamplePoint(intf(j), fclassInt, bb1, mass1);
|
||||
if (st == TopAbs_OUT) //note that intf-faces are holes
|
||||
intfInd.Add(j);
|
||||
}
|
||||
@@ -1142,10 +1072,14 @@ static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
BRep_Builder().Add(cf, int_wire);
|
||||
}
|
||||
gp_Pnt2d p2d;
|
||||
gp_Pnt p3d;
|
||||
TopExp_Explorer exp(cf, TopAbs_EDGE);
|
||||
gp_Pnt p3d;
|
||||
Handle(IntTools_Context) context = new IntTools_Context();
|
||||
BOPTools_AlgoTools3D::PointNearEdge( TopoDS::Edge(exp.Current()), cf, p2d, p3d, context);
|
||||
int ierr = BOPTools_AlgoTools3D::PointInFace( cf, p3d, p2d, context);
|
||||
if (ierr)
|
||||
{
|
||||
TopExp_Explorer exp(cf, TopAbs_EDGE);
|
||||
BOPTools_AlgoTools3D::PointNearEdge( TopoDS::Edge(exp.Current()), cf, p2d, p3d, context);
|
||||
}
|
||||
gp_Lin shot_line = projector.Shoot(p2d.X(), p2d.Y());
|
||||
|
||||
aSelFL.ResetResult();
|
||||
@@ -1159,7 +1093,10 @@ static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
if (theMode)
|
||||
{
|
||||
std::sort(fp.begin(), fp.end(), HLRBRep_ParComp);
|
||||
OrigFaceToProjFace.Bind(cf, fp.front().myF);
|
||||
TopoDS_Face orF ;
|
||||
orF = fp.front().myF;
|
||||
OrigFaceToProjFace.Bind(orF, cf);
|
||||
ProjFaceToOrigFace.Bind(cf, orF);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1168,7 +1105,8 @@ static TopoDS_Shape ProcessLoops(const TopoDS_Shape& theRes,
|
||||
}
|
||||
|
||||
TopoDS_Shape HLRBRep_HLRToShape::CompoundOfFaces(bool theMode,
|
||||
TopTools_DataMapOfShapeShape& OrigFaceToProjFace)
|
||||
TopTools_DataMapOfShapeShape& OrigFaceToProjFace,
|
||||
TopTools_DataMapOfShapeShape& ProjFaceToOrigFace)
|
||||
{
|
||||
//
|
||||
TopTools_ListOfShape anOrigShapes;
|
||||
@@ -1197,12 +1135,11 @@ TopoDS_Shape HLRBRep_HLRToShape::CompoundOfFaces(bool theMode,
|
||||
if( !FuseVE (aTotalOSh))
|
||||
return TopoDS_Shape();
|
||||
//
|
||||
NCollection_DataMap<TopoDS_Edge, Bnd_Box2d, TopTools_ShapeMapHasher> theEdBnd2d;
|
||||
NCollection_IndexedDataMap<TopoDS_Edge, BRepAdaptor_Curve2d, TopTools_ShapeMapHasher> anEdAd;
|
||||
ProcessHVertices(aTotalOSh, anEdAd, theEdBnd2d);
|
||||
ProcessHVertices(aTotalOSh, anEdAd);
|
||||
//
|
||||
TopoDS_Shape aRes = ProcessLoops(aTotalOSh, anEdAd, theEdBnd2d,
|
||||
myAlgo->Projector(), anOrigShapes, theMode, OrigFaceToProjFace);
|
||||
TopoDS_Shape aRes = ProcessLoops(aTotalOSh, anEdAd, myAlgo->Projector(), anOrigShapes, theMode,
|
||||
OrigFaceToProjFace, ProjFaceToOrigFace);
|
||||
//
|
||||
return aRes;
|
||||
}
|
||||
|
@@ -133,7 +133,8 @@ public:
|
||||
const Standard_Boolean In3d);
|
||||
|
||||
TopoDS_Shape CompoundOfFaces (bool theMode,
|
||||
TopTools_DataMapOfShapeShape& OrigFaceToProjFace);
|
||||
TopTools_DataMapOfShapeShape& OrigFaceToProjFace,
|
||||
TopTools_DataMapOfShapeShape& ProjFaceToOrigFace);
|
||||
|
||||
|
||||
protected:
|
||||
|
@@ -292,7 +292,7 @@ static bool ClarifyPoint(math_FunctionSetRoot& rsnld, Contap_SurfFunction& SFunc
|
||||
TopAbs_State state = const_cast<BRepTopAdaptor_TopolTool*>(Domain)
|
||||
->Classify(P2d,Precision::PConfusion());
|
||||
if (state == TopAbs_IN || state == TopAbs_ON)
|
||||
{
|
||||
{
|
||||
const Handle(Adaptor3d_HSurface)& Surf = SFunc.Surface();
|
||||
p3d = Adaptor3d_HSurfaceTool::Value(Surf,P2d.X(),P2d.Y());
|
||||
return true;
|
||||
@@ -309,7 +309,8 @@ static bool ClarifyPoint(math_FunctionSetRoot& rsnld, Contap_SurfFunction& SFunc
|
||||
|
||||
void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/,
|
||||
const TopoDS_Face& F,
|
||||
Contap_Contour& FO, const BRepTopAdaptor_TopolTool* Domain,
|
||||
Contap_Contour& FO,
|
||||
const BRepTopAdaptor_TopolTool* Domain,
|
||||
HLRTopoBRep_Data& DS,
|
||||
const Standard_Boolean withPCurve)
|
||||
{
|
||||
@@ -385,8 +386,8 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/,
|
||||
Standard_Boolean InsuffisantNumberOfPoints=Standard_False;
|
||||
|
||||
switch (Line.TypeContour()) {
|
||||
|
||||
case Contap_Lin :
|
||||
|
||||
case Contap_Lin :
|
||||
{
|
||||
C = new Geom_Line(Line.Line());
|
||||
if (withPCurve) {
|
||||
@@ -396,8 +397,8 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/,
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Contap_Circle :
|
||||
|
||||
case Contap_Circle :
|
||||
{
|
||||
C = new Geom_Circle(Line.Circle());
|
||||
if (withPCurve) {
|
||||
@@ -411,89 +412,89 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/,
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Contap_Walking :
|
||||
|
||||
case Contap_Walking :
|
||||
{
|
||||
// copy the points
|
||||
Standard_Integer ipF = Standard_Integer(parF);
|
||||
Standard_Integer ipL = Standard_Integer(parL);
|
||||
|
||||
|
||||
if(ipL-ipF < 1) {
|
||||
InsuffisantNumberOfPoints=Standard_True;
|
||||
//cout<<"\n !! Pb ds HLRTopoBRep_DSFiller.cxx (Contour App Nbp <3)"<<endl;
|
||||
}
|
||||
/*
|
||||
else if(ipL-ipF < 6) {
|
||||
// compute the tangents
|
||||
Contap_SurfFunction& SFunc =
|
||||
FO.SurfaceFunction();
|
||||
|
||||
Standard_Boolean isTg1,isTg2;
|
||||
gp_Vec tg1,tg2;
|
||||
gp_Vec2d uv1,uv2;
|
||||
math_Vector UV(1,2),F(1,1);
|
||||
|
||||
Line.Point(ipF).ParametersOnS2(UV(1),UV(2));
|
||||
SFunc.Value(UV,F);
|
||||
isTg1 = SFunc.IsTangent();
|
||||
if (!isTg1) {
|
||||
tg1 = SFunc.Direction3d();
|
||||
if (withPCurve) uv1 = SFunc.Direction2d();
|
||||
}
|
||||
|
||||
Line.Point(ipL).ParametersOnS2(UV(1),UV(2));
|
||||
SFunc.Value(UV,F);
|
||||
isTg2 = SFunc.IsTangent();
|
||||
if (!isTg2) {
|
||||
tg2 = SFunc.Direction3d();
|
||||
if (withPCurve) uv2 = SFunc.Direction2d();
|
||||
}
|
||||
// interpolate
|
||||
Standard_Integer nbp = ipL - ipF + 1;
|
||||
AppDef_MultiLine MLine(nbp);
|
||||
Standard_Integer nb2d = 0;
|
||||
if (withPCurve) nb2d = 1;
|
||||
|
||||
for (Standard_Integer i = 1; i <= nbp; i++) {
|
||||
AppDef_MultiPointConstraint MP(1, nb2d);
|
||||
MP.SetPoint(1,Line.Point(i + ipF - 1).Value());
|
||||
if (withPCurve) {
|
||||
Line.Point(i + ipF - 1).ParametersOnS2(UV(1),UV(2));
|
||||
MP.SetPoint2d(2,gp_Pnt2d(UV(1),UV(2)));
|
||||
}
|
||||
|
||||
if (i == 1 && !isTg1) {
|
||||
MP.SetTang (1,tg1);
|
||||
if (withPCurve) MP.SetTang2d(2,uv1);
|
||||
}
|
||||
if (i == nbp && !isTg2) {
|
||||
MP.SetTang (1,tg2);
|
||||
if (withPCurve) MP.SetTang2d(2,uv2);
|
||||
}
|
||||
MLine.SetValue(i,MP);
|
||||
}
|
||||
AppDef_BSplineCompute interp;
|
||||
interp.Interpol(MLine);
|
||||
AppParCurves_MultiBSpCurve TheCurve = interp.Value();
|
||||
Standard_Integer Degree = TheCurve.Degree();
|
||||
TColgp_Array1OfPnt Poles(1,TheCurve.NbPoles());
|
||||
TheCurve.Curve(1,Poles);
|
||||
C = new Geom_BSplineCurve(Poles,
|
||||
TheCurve.Knots(),
|
||||
TheCurve.Multiplicities(),
|
||||
Degree);
|
||||
if (withPCurve) {
|
||||
TColgp_Array1OfPnt2d Pol2d(1,TheCurve.NbPoles());
|
||||
TheCurve.Curve(2,Pol2d);
|
||||
C2d = new Geom2d_BSplineCurve(Pol2d,
|
||||
TheCurve.Knots(),
|
||||
TheCurve.Multiplicities(),
|
||||
Degree);
|
||||
}
|
||||
first = 0;
|
||||
last = 1;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
else if(ipL-ipF < 6) {
|
||||
// compute the tangents
|
||||
Contap_SurfFunction& SFunc =
|
||||
FO.SurfaceFunction();
|
||||
|
||||
Standard_Boolean isTg1,isTg2;
|
||||
gp_Vec tg1,tg2;
|
||||
gp_Vec2d uv1,uv2;
|
||||
math_Vector UV(1,2),F(1,1);
|
||||
|
||||
Line.Point(ipF).ParametersOnS2(UV(1),UV(2));
|
||||
SFunc.Value(UV,F);
|
||||
isTg1 = SFunc.IsTangent();
|
||||
if (!isTg1) {
|
||||
tg1 = SFunc.Direction3d();
|
||||
if (withPCurve) uv1 = SFunc.Direction2d();
|
||||
}
|
||||
|
||||
Line.Point(ipL).ParametersOnS2(UV(1),UV(2));
|
||||
SFunc.Value(UV,F);
|
||||
isTg2 = SFunc.IsTangent();
|
||||
if (!isTg2) {
|
||||
tg2 = SFunc.Direction3d();
|
||||
if (withPCurve) uv2 = SFunc.Direction2d();
|
||||
}
|
||||
// interpolate
|
||||
Standard_Integer nbp = ipL - ipF + 1;
|
||||
AppDef_MultiLine MLine(nbp);
|
||||
Standard_Integer nb2d = 0;
|
||||
if (withPCurve) nb2d = 1;
|
||||
|
||||
for (Standard_Integer i = 1; i <= nbp; i++) {
|
||||
AppDef_MultiPointConstraint MP(1, nb2d);
|
||||
MP.SetPoint(1,Line.Point(i + ipF - 1).Value());
|
||||
if (withPCurve) {
|
||||
Line.Point(i + ipF - 1).ParametersOnS2(UV(1),UV(2));
|
||||
MP.SetPoint2d(2,gp_Pnt2d(UV(1),UV(2)));
|
||||
}
|
||||
|
||||
if (i == 1 && !isTg1) {
|
||||
MP.SetTang (1,tg1);
|
||||
if (withPCurve) MP.SetTang2d(2,uv1);
|
||||
}
|
||||
if (i == nbp && !isTg2) {
|
||||
MP.SetTang (1,tg2);
|
||||
if (withPCurve) MP.SetTang2d(2,uv2);
|
||||
}
|
||||
MLine.SetValue(i,MP);
|
||||
}
|
||||
AppDef_BSplineCompute interp;
|
||||
interp.Interpol(MLine);
|
||||
AppParCurves_MultiBSpCurve TheCurve = interp.Value();
|
||||
Standard_Integer Degree = TheCurve.Degree();
|
||||
TColgp_Array1OfPnt Poles(1,TheCurve.NbPoles());
|
||||
TheCurve.Curve(1,Poles);
|
||||
C = new Geom_BSplineCurve(Poles,
|
||||
TheCurve.Knots(),
|
||||
TheCurve.Multiplicities(),
|
||||
Degree);
|
||||
if (withPCurve) {
|
||||
TColgp_Array1OfPnt2d Pol2d(1,TheCurve.NbPoles());
|
||||
TheCurve.Curve(2,Pol2d);
|
||||
C2d = new Geom2d_BSplineCurve(Pol2d,
|
||||
TheCurve.Knots(),
|
||||
TheCurve.Multiplicities(),
|
||||
Degree);
|
||||
}
|
||||
first = 0;
|
||||
last = 1;
|
||||
}
|
||||
*/
|
||||
else if(ipL-ipF < 5) {
|
||||
const Standard_Integer nbp = ipL - ipF + 1;
|
||||
TColStd_Array1OfReal knots(1,nbp);
|
||||
@@ -507,7 +508,7 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/,
|
||||
}
|
||||
mults(1)=mults(nbp)=2;
|
||||
C = new Geom_BSplineCurve(Points,knots,mults,1);
|
||||
|
||||
|
||||
if(withPCurve) {
|
||||
TColgp_Array1OfPnt2d Points2d(1,nbp);
|
||||
for(Standard_Integer i=1;i<=nbp;i++) {
|
||||
@@ -530,84 +531,39 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/,
|
||||
Standard_Real Minx,Miny,Minz,Minu,Minv;
|
||||
Maxx=Maxy=Maxz=Maxu=Maxv=-RealLast();
|
||||
Minx=Miny=Minz=Minu=Minv=RealLast();
|
||||
|
||||
for(Standard_Integer i=1;i<=nbp;i++)
|
||||
{
|
||||
knots.SetValue(i,(Standard_Real)i);
|
||||
mults.SetValue(i,1);
|
||||
const gp_Pnt& P= Line.Point(i+ipF-1).Value();
|
||||
if(P.X()<Minx) Minx=P.X();
|
||||
if(P.Y()<Miny) Miny=P.Y();
|
||||
if(P.Z()<Minz) Minz=P.Z();
|
||||
if(P.X()>Maxx) Maxx=P.X();
|
||||
if(P.Y()>Maxy) Maxy=P.Y();
|
||||
if(P.Z()>Maxz) Maxz=P.Z();
|
||||
Points.SetValue(i,P);
|
||||
}
|
||||
mults(1)=mults(nbp)=2;
|
||||
//Handle(Geom_BSplineCurve) AppC;
|
||||
//Handle(Geom2d_BSplineCurve) AppC2d;
|
||||
//AppC = new Geom_BSplineCurve(Points,knots,mults,1);
|
||||
|
||||
|
||||
TColgp_Array1OfPnt2d Points2d(1,nbp);
|
||||
for(Standard_Integer i=1;i<=nbp;i++)
|
||||
{
|
||||
Standard_Real u,v;
|
||||
Line.Point(i+ipF-1).ParametersOnS2(u,v);
|
||||
if(u<Minu) Minu=u;
|
||||
if(v<Minv) Minv=v;
|
||||
if(u>Maxu) Maxu=u;
|
||||
if(v>Maxv) Maxv=v;
|
||||
Points2d.SetValue(i,gp_Pnt2d(u,v));
|
||||
}
|
||||
//AppC2d = new Geom2d_BSplineCurve(Points2d,knots,mults,1);
|
||||
|
||||
first = 1;
|
||||
last = nbp;
|
||||
|
||||
//Handle(BRepApprox_ApproxLine) AppLine;
|
||||
Handle(Geom2d_BSplineCurve) CNull;
|
||||
//AppLine = new BRepApprox_ApproxLine(AppC,AppC2d,CNull);
|
||||
|
||||
|
||||
Standard_Integer dmin=4,dmax=8,niter=0;
|
||||
Standard_Boolean tg= Standard_False;
|
||||
BRepApprox_Approx Approx;
|
||||
Standard_Real TOL3d,TOL2d,TOL=0.0001;
|
||||
|
||||
Maxx-=Minx; Maxy-=Miny; Maxz-=Minz;
|
||||
Maxu-=Minu; Maxv-=Minv;
|
||||
if(Maxy>Maxx) Maxx=Maxy;
|
||||
if(Maxz>Maxx) Maxx=Maxy;
|
||||
if(Maxv>Maxu) Maxu=Maxv;
|
||||
|
||||
TOL3d=TOL*Maxx; if(TOL3d<1e-12) TOL3d=1e-12; else if(TOL3d>0.1) TOL3d=0.1;
|
||||
TOL2d=TOL*Maxu; if(TOL2d<1e-12) TOL2d=1e-12; else if(TOL2d>0.1) TOL2d=0.1;
|
||||
|
||||
Contap_SurfFunction& SFunc = FO.SurfaceFunction();
|
||||
const Handle(Adaptor3d_HSurface)& Surf = SFunc.Surface();
|
||||
|
||||
double cmax = 2.0;
|
||||
double c = 100;
|
||||
int newsize;
|
||||
int newsize = 0;
|
||||
|
||||
NCollection_List<gp_Pnt2d> lp2d;
|
||||
NCollection_List<gp_Pnt> lp;
|
||||
|
||||
lp2d.Append(Points2d.First());
|
||||
lp.Append(Points.First());
|
||||
for (int jj=2; jj < Points.Size(); jj++ )
|
||||
gp_Pnt firstPnt = Line.Point(ipF).Value();
|
||||
gp_Pnt2d firstPnt2d = Line.Point(ipF).ValueOnSurface(Standard_False);
|
||||
lp2d.Append(firstPnt2d/*Points2d.First()*/);
|
||||
lp.Append(firstPnt/*Points.First()*/);
|
||||
|
||||
|
||||
for (Standard_Integer jj=2;jj<=nbp-1;jj++)
|
||||
{
|
||||
gp_Pnt curPnt = Points(jj);
|
||||
gp_Pnt2d curPnt2d = Points2d(jj);
|
||||
const gp_Pnt& curPnt= Line.Point(jj+ipF-1).Value();
|
||||
gp_Pnt2d curPnt2d = Line.Point(jj+ipF-1).ValueOnSurface(Standard_False);
|
||||
gp_Pnt2d nextPnt2d = Line.Point(jj+ipF).ValueOnSurface(Standard_False);
|
||||
double x0 = curPnt2d.X(), y0= curPnt2d.Y();
|
||||
double d3_1 = lp.Last().Distance(curPnt);
|
||||
double d3_2 = curPnt.Distance(Points(jj+1));
|
||||
|
||||
double d1 = lp2d.Last().Distance(Points2d(jj));
|
||||
double d2 = Points2d(jj).Distance(Points2d(jj+1));
|
||||
|
||||
double x0 = curPnt2d.X();
|
||||
double y0 = curPnt2d.Y();
|
||||
double d3_2 = curPnt.Distance(Line.Point(jj+ipF).Value());
|
||||
double d1 = lp2d.Last().Distance(curPnt2d);
|
||||
double d2 = curPnt2d.Distance(nextPnt2d);
|
||||
|
||||
double coeff = d3_1/d3_2;
|
||||
c = 1.4;
|
||||
@@ -650,8 +606,8 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/,
|
||||
double t = 0;
|
||||
lp2d.Append(curPnt2d);
|
||||
lp.Append(curPnt);
|
||||
double x1 = Points2d(jj+1).X();
|
||||
double y1 = Points2d(jj+1).Y();
|
||||
double x1 = nextPnt2d.X();
|
||||
double y1 = nextPnt2d.Y();
|
||||
math_Vector tol(1,2), inf(1,2), sup(1,2);
|
||||
GetSurfInfo(Surf, tol, inf, sup);
|
||||
math_FunctionSetRoot rsnld(SFunc,tol,50);
|
||||
@@ -680,8 +636,8 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/,
|
||||
lp.Append(curPnt);
|
||||
}
|
||||
}
|
||||
lp2d.Append(Points2d.Last());
|
||||
lp.Append(Points.Last());
|
||||
lp2d.Append(Line.Point(ipL).ValueOnSurface(Standard_False));
|
||||
lp.Append(Line.Point(ipL).Value());
|
||||
//
|
||||
|
||||
newsize = lp.Size();
|
||||
@@ -694,11 +650,37 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/,
|
||||
NCollection_List<gp_Pnt2d>::Iterator itl2(lp2d);
|
||||
for (int jj = 1;itl.More(), itl2.More();itl.Next(), itl2.Next(), jj++)
|
||||
{
|
||||
const gp_Pnt& P= itl.Value();
|
||||
if(P.X()<Minx) Minx=P.X();
|
||||
if(P.Y()<Miny) Miny=P.Y();
|
||||
if(P.Z()<Minz) Minz=P.Z();
|
||||
if(P.X()>Maxx) Maxx=P.X();
|
||||
if(P.Y()>Maxy) Maxy=P.Y();
|
||||
if(P.Z()>Maxz) Maxz=P.Z();
|
||||
//
|
||||
const gp_Pnt2d& P2d = itl2.Value();
|
||||
if(P2d.X()<Minu) Minu=P2d.X();
|
||||
if(P2d.Y()<Minv) Minv=P2d.Y();
|
||||
if(P2d.X()>Maxu) Maxu=P2d.X();
|
||||
if(P2d.Y()>Maxv) Maxv=P2d.Y();
|
||||
|
||||
nknots.SetValue(jj,(Standard_Real)jj);
|
||||
nmults.SetValue(jj,1);
|
||||
newPoints2dA.SetValue(jj, itl2.Value());
|
||||
newPoints3dA.SetValue(jj, itl.Value());
|
||||
newPoints2dA.SetValue(jj, P2d);
|
||||
newPoints3dA.SetValue(jj, P);
|
||||
}
|
||||
|
||||
Standard_Real TOL3d,TOL2d,TOL=0.0001;
|
||||
|
||||
Maxx-=Minx; Maxy-=Miny; Maxz-=Minz;
|
||||
Maxu-=Minu; Maxv-=Minv;
|
||||
if(Maxy>Maxx) Maxx=Maxy;
|
||||
if(Maxz>Maxx) Maxx=Maxy;
|
||||
if(Maxv>Maxu) Maxu=Maxv;
|
||||
|
||||
TOL3d=TOL*Maxx; if(TOL3d<1e-12) TOL3d=1e-12; else if(TOL3d>0.1) TOL3d=0.1;
|
||||
TOL2d=TOL*Maxu; if(TOL2d<1e-12) TOL2d=1e-12; else if(TOL2d>0.1) TOL2d=0.1;
|
||||
|
||||
nmults(1)=nmults(newsize)=2;
|
||||
Handle_BRepApprox_ApproxLine nAppLine ;
|
||||
Handle(Geom_BSplineCurve) nAppC =
|
||||
@@ -708,10 +690,6 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/,
|
||||
|
||||
nAppLine = new BRepApprox_ApproxLine(nAppC,nAppC2d,CNull);
|
||||
|
||||
|
||||
//AppC2d = new Geom2d_BSplineCurve(Points2d,knots,mults,1);
|
||||
//-- cout<<"\nHLRTopoBRep_DSFiller : nbp="<<nbp<<" Tol3d="<<TOL3d<<" Tol2d="<<TOL2d<<endl;
|
||||
|
||||
Approx.SetParameters(TOL3d, TOL2d, dmin, dmax, niter, 30, tg);
|
||||
Approx.Perform(nAppLine,Standard_True,Standard_True,Standard_False,1,newsize/*nbp*/);
|
||||
if (!Approx.IsDone()) {
|
||||
|
@@ -1737,13 +1737,169 @@ static Standard_Integer OCC28991 (Draw_Interpretor& , Standard_Integer n, const
|
||||
|
||||
Reflector.Perform();
|
||||
|
||||
TopTools_DataMapOfShapeShape aDummy;
|
||||
TopoDS_Shape aFaces = Reflector.GetCompoundOfFaces(true, aDummy);
|
||||
TopTools_DataMapOfShapeShape aDummy, aDummy2;
|
||||
TopoDS_Shape aFaces = Reflector.GetCompoundOfFaces(true, aDummy, aDummy2);
|
||||
|
||||
DBRep::Set(a[1], aFaces);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#include <XCAFDoc_ColorTool.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <XCAFDoc.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
#include <ViewerTest.hxx>
|
||||
static Standard_Integer OCC_HLRDEMO (Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n != 4)
|
||||
{
|
||||
cout << "Use: hlrdemo resDoc inpDoc axo/top/bottom/front/back/left/right" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) aDoc;
|
||||
DDocStd::GetDocument(a[2], aDoc);
|
||||
if ( aDoc.IsNull() )
|
||||
return 1;
|
||||
|
||||
TDF_LabelSequence Labels;
|
||||
Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
|
||||
STool->GetFreeShapes(Labels);
|
||||
if ( Labels.Length() <=0 )
|
||||
{
|
||||
cout << "no shapes" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
TopoDS_Compound aShape;
|
||||
BRep_Builder B;
|
||||
B.MakeCompound ( aShape );
|
||||
for ( int i = 1; i <= Labels.Length(); i++)
|
||||
{
|
||||
TopoDS_Shape S = STool->GetShape ( Labels.Value(i) );
|
||||
B.Add ( aShape, S );
|
||||
}
|
||||
//
|
||||
|
||||
gp_Pnt anOrigin(0.,0.,0.);
|
||||
gp_Dir aNormal(0.57735026918962573, -0.57735026918962573, 0.57735026918962573);
|
||||
gp_Ax2 anAxes(anOrigin, aNormal);
|
||||
gp_Dir aDX = anAxes.XDirection();
|
||||
|
||||
HLRAppli_ReflectLines Reflector(aShape);
|
||||
|
||||
bool from_view = false;
|
||||
if (strcmp(a[3],"from_view") == 0)
|
||||
{
|
||||
Handle(V3d_View) aView = ViewerTest::CurrentView();
|
||||
if (aView.IsNull())
|
||||
return 1;
|
||||
from_view = true;
|
||||
//Standard_Real aViewScale = aView->Scale();
|
||||
//Standard_Real aViewSize = 1.0;
|
||||
//Graphic3d_Vec2i aCenter2d;
|
||||
//gp_XYZ aViewProj, aViewUp, aViewAt, aViewEye;
|
||||
//aView->Proj (aViewProj.ChangeCoord (1), aViewProj.ChangeCoord (2), aViewProj.ChangeCoord (3));
|
||||
//aView->Up (aViewUp .ChangeCoord (1), aViewUp .ChangeCoord (2), aViewUp .ChangeCoord (3));
|
||||
//aView->At (aViewAt .ChangeCoord (1), aViewAt .ChangeCoord (2), aViewAt .ChangeCoord (3));
|
||||
//aView->Eye (aViewEye .ChangeCoord (1), aViewEye .ChangeCoord (2), aViewEye .ChangeCoord (3));
|
||||
|
||||
//anOrigin.SetXYZ(aViewEye);
|
||||
//aNormal.SetXYZ(aViewProj);
|
||||
//aDX.SetXYZ(aViewUp);
|
||||
|
||||
Handle(Graphic3d_Camera) aCamera = aView->Camera();
|
||||
const gp_Dir aDir = aCamera->Direction().Reversed();
|
||||
const gp_Pnt anAt = aCamera->Center();
|
||||
const gp_Dir anUp = aCamera->Up();
|
||||
|
||||
Reflector.SetAxes(aDir.X(), aDir.Y(), aDir.Z(),
|
||||
anAt.X(), anAt.Y(), anAt.Z(),
|
||||
anUp.X(), anUp.Y(), anUp.Z(),
|
||||
!aCamera->IsOrthographic(),
|
||||
aCamera->Scale());
|
||||
|
||||
}
|
||||
else if (strcmp(a[3],"axo") == 0)
|
||||
{
|
||||
aNormal.SetCoord(0.57735026918962573, -0.57735026918962573, 0.57735026918962573);
|
||||
aDX.SetCoord(-0.40824829046386307, 0.40824829046386307, 0.81649658092772615);
|
||||
}
|
||||
else if (strcmp(a[3],"top") == 0)
|
||||
{
|
||||
aNormal.SetCoord(0,0,1);
|
||||
aDX.SetCoord(0,1,0);
|
||||
}
|
||||
else if (strcmp(a[3],"bottom") == 0)
|
||||
{
|
||||
aNormal.SetCoord(0,0,-1);
|
||||
aDX.SetCoord(0,-1,0);
|
||||
}
|
||||
else if (strcmp(a[3],"front") == 0)
|
||||
{
|
||||
aNormal.SetCoord(0,-1,0);
|
||||
aDX.SetCoord(0,0,1);
|
||||
}
|
||||
else if (strcmp(a[3],"back") == 0)
|
||||
{
|
||||
aNormal.SetCoord(0,1,0);
|
||||
aDX.SetCoord(0,0,1);
|
||||
}
|
||||
else if (strcmp(a[3],"left") == 0)
|
||||
{
|
||||
aNormal.SetCoord(-1,0,0);
|
||||
aDX.SetCoord(0,0,1);
|
||||
}
|
||||
else if (strcmp(a[3],"right") == 0)
|
||||
{
|
||||
aNormal.SetCoord(1,0,0);
|
||||
aDX.SetCoord(0,0,1);
|
||||
}
|
||||
|
||||
if (!from_view)
|
||||
Reflector.SetAxes(aNormal.X(), aNormal.Y(), aNormal.Z(),
|
||||
anOrigin.X(), anOrigin.Y(), anOrigin.Z(),
|
||||
aDX.X(), aDX.Y(), aDX.Z());
|
||||
|
||||
Reflector.Perform();
|
||||
|
||||
TopTools_DataMapOfShapeShape map3Dto2Dfaces, map2Dto3Dfaces;
|
||||
TopoDS_Shape aFaces = Reflector.GetCompoundOfFaces(true, map3Dto2Dfaces, map2Dto3Dfaces);
|
||||
|
||||
Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( aDoc->Main() );
|
||||
|
||||
Handle(TDocStd_Document) OutDoc;
|
||||
DDocStd::GetDocument(a[1], OutDoc);
|
||||
if ( OutDoc.IsNull() )
|
||||
{
|
||||
di << a[2] << " is not a document\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TopExp_Explorer exp(aFaces, TopAbs_FACE);
|
||||
Handle(XCAFDoc_ShapeTool) SToolOut = XCAFDoc_DocumentTool::ShapeTool(OutDoc->Main());
|
||||
Handle(XCAFDoc_ColorTool) CToolOut = XCAFDoc_DocumentTool::ColorTool(OutDoc->Main());
|
||||
|
||||
for (;exp.More();exp.Next())
|
||||
{
|
||||
TopoDS_Shape aCShape = exp.Current();
|
||||
TDF_Label aLabel;
|
||||
aLabel = SToolOut->AddShape(aCShape, 0);
|
||||
if (aLabel.IsNull())
|
||||
continue;
|
||||
|
||||
const TopoDS_Shape& a3df = map2Dto3Dfaces(aCShape);
|
||||
Quantity_Color aQColor;
|
||||
if (!CTool->GetColor ( a3df, XCAFDoc_ColorGen, aQColor) )
|
||||
continue;
|
||||
CToolOut->SetColor(aLabel, aQColor, XCAFDoc_ColorGen);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
@@ -2623,8 +2779,13 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
|
||||
"OCC27341 res shape axo/top/bottom/front/back/left/right",
|
||||
__FILE__, OCC27341, group);
|
||||
theCommands.Add("OCC28991",
|
||||
"OCC289911 res shape axo/top/bottom/front/back/left/right",
|
||||
"OCC28991 res shape axo/top/bottom/front/back/left/right",
|
||||
__FILE__, OCC28991, group);
|
||||
|
||||
theCommands.Add("OCC_HLRDEMO",
|
||||
"OCC_HLRDEMO outdoc inpdoc axo/top/bottom/front/back/left/right",
|
||||
__FILE__, OCC_HLRDEMO, group);
|
||||
|
||||
theCommands.Add ("OCC26747_1", "OCC26747_1 result", __FILE__, OCC26747_1, group);
|
||||
theCommands.Add ("OCC26747_2", "OCC26747_2 result", __FILE__, OCC26747_2, group);
|
||||
theCommands.Add ("OCC26747_3", "OCC26747_3 result", __FILE__, OCC26747_3, group);
|
||||
@@ -2642,5 +2803,7 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
|
||||
__FILE__, OCC28887, group);
|
||||
theCommands.Add("OCC28131", "OCC28131 name: creates face problematic for offset", __FILE__, OCC28131, group);
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user