#include <BRepLib_MakeEdge.hxx>
#include <BRepLib_MakeWire.hxx>
#include <BRep_Builder.hxx>
+#include <ShapeAnalysis_Wire.hxx>
+#include <BRepAlgo_NormalProjection.hxx>
+#include <BRepBuilderAPI_MakePolygon.hxx>
IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry )
-
HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv, const gp_Vec2d& theProfileDir, double theDeltaZ )
: myXcurv( theXCurv ), myProfileDir( theProfileDir ), myDeltaZ( theDeltaZ )
{
void HYDROData_DTM::PointToWire(const AltitudePoints& pnts, TopoDS_Wire& W )
{
- BRepLib_MakeWire WM;
+ /*BRepLib_MakeWire WM;
if (pnts.empty())
return;
for (int i = 0; i < pnts.size() - 1; i++)
gp_Pnt p2(pnts[i+1].X, pnts[i+1].Y, pnts[i+1].Z);
WM.Add(BRepLib_MakeEdge(p1, p2).Edge());
}
- if (WM.IsDone())
- W = WM.Wire();
+ if (WM.IsDone())*/
+
+ BRepBuilderAPI_MakePolygon PM;
+ for (int i = 0; i < pnts.size(); i++)
+ PM.Add(gp_Pnt(pnts[i].X, pnts[i].Y, pnts[i].Z));
+
+ W = PM.Wire();
}
TopTools_IndexedMapOfOrientedShape HYDROData_DTM::Create3DShape(const AltitudePoints& left,
double ddz = GetDDZ();
double step = GetSpatialStep();
std::set<int> InvInd;
- CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, InvInd, -1 );
+ bool WireIntersections; //__TODO
+ CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, InvInd, -1, WireIntersections );
SetAltitudePoints( points );
SetShape( DataTag_LeftBankShape, OutLeftB);
Out3dPres = GetShape( DataTag_3DShape );
Out2dPres = GetShape( DataTag_2DShape );
}
-
void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& InpProfiles,
double ddz,
double step,
bool Create3dPres,
bool Create2dPres,
std::set<int>& InvInd,
- int thePntsLimit )
+ int thePntsLimit,
+ bool& WireIntersections)
{
int aLower = InpProfiles.Lower(), anUpper = InpProfiles.Upper();
size_t n = anUpper - aLower + 1;
if( ddz>EPS && step>EPS )
CreateProfiles(profiles, ddz, step, left, right, points, main_profiles,
- Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, Create2dPres, InvInd );
+ Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, Create2dPres, InvInd, WireIntersections );
}
void HYDROData_DTM::ProjWireOnPlane(const TopoDS_Wire& inpWire, const Handle_Geom_Plane& RefPlane, TopoDS_Wire& outWire)
{
- //its also possible to use BrepAlgo_NormalProjection here!
- BRepTools_WireExplorer ex(TopoDS::Wire(inpWire.Oriented(TopAbs_FORWARD)));
+ /*BRepTools_WireExplorer ex(TopoDS::Wire(inpWire.Oriented(TopAbs_FORWARD)));
BRepLib_MakeWire WM;
for (;ex.More();ex.Next())
{
double f, l;
Handle(Geom_Curve) C3d = BRep_Tool::Curve(CE, f, l);
Handle(Geom_Curve) ProjectedCurve = GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d, f, l), RefPlane, RefPlane->Position().Direction(), Standard_True);
- TopoDS_Edge ProjEdge = BRepLib_MakeEdge(ProjectedCurve);
- WM.Add(ProjEdge); //auto sharing between edges if vertex is coincident
- }
+ if (!ProjectedCurve.IsNull())
+ {
+ TopoDS_Edge ProjEdge = BRepLib_MakeEdge(ProjectedCurve, f, l );
+ if (!BRep_Tool::Degenerated(ProjEdge))
+ WM.Add(ProjEdge); //auto sharing between edges if vertex is coincident
+ }
+ }*/
+
+ BRep_Builder BB;
+ TopoDS_Face F;
+ BB.MakeFace(F, RefPlane, Precision::Confusion());
+ BRepLib_MakeWire WM;
+
+ BRepAlgo_NormalProjection nproj(F);
+ nproj.Add(inpWire);
+ nproj.SetDefaultParams();
+ nproj.Build();
+ if(!nproj.IsDone())
+ return;
+ TopoDS_Shape projRes = nproj.Projection();
+ TopExp_Explorer exp(projRes, TopAbs_EDGE);
+ TopTools_ListOfShape llE;
+ for (;exp.More();exp.Next())
+ llE.Append(exp.Current());
+
+ WM.Add(llE);
outWire = WM.Wire();
+
outWire.Orientation(inpWire.Orientation()); //take from the original wire
}
-void HYDROData_DTM::Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF )
+bool HYDROData_DTM::Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF )
{
Handle_Geom_Plane refpl = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1));
BRepLib_MakeWire WM;
TopoDS_Wire outW;
ProjWireOnPlane(WM.Wire(), refpl, outW);
- BRepBuilderAPI_MakeFace mf(refpl, outW); //check inside is true by def
+ BRepBuilderAPI_MakeFace mf(refpl, outW, true); //check inside is true by def
outF = mf.Face();
+ ShapeAnalysis_Wire WA(outW, outF, Precision::Confusion());
+ bool res = WA.CheckSelfIntersection();
+ return res;
+
///!!! the internal wires cant be added with 'internal' ori.
// it's possible to do with brep builder yet the result will not be correct!
// more proper way is to use BOP operation here.
TopoDS_Shape& OutOutlet,
bool Create3dPres,
bool Create2dPres,
- std::set<int>& InvInd)
+ std::set<int>& InvInd,
+ bool& WireIntersections)
{
if (theProfiles.empty())
return;
if (Create2dPres)
{
TopoDS_Face outF;
- Get2dFaceFrom3dPres(cmp, outF);
+ WireIntersections = Get2dFaceFrom3dPres(cmp, outF); //__TODO
Out2dPres = outF;
};
}
}
thePoints.reserve( sorted_points.size() );
+ const double EPS = 1E-12;
std::map<double, AltitudePoint>::const_iterator it = sorted_points.begin(), last = sorted_points.end();
for( ; it!=last; it++ )
- thePoints.push_back( it->second );
+ if( thePoints.empty() || thePoints.back().SquareDistance( it->second ) > EPS )
+ thePoints.push_back( it->second );
}
inline double max( double a, double b )