}
-double CalcGC( const std::vector<gp_Pnt2d>& intersections )
-{
- double u = 0;
- size_t n = intersections.size();
- for( size_t i = 0; i < n; i++ )
- {
- u += intersections[i].X();
- }
- u /= n;
- return u;
-}
-
-double CalcWidth( const std::vector<gp_Pnt2d>& intersections )
+bool CalcMidWidth( const std::vector<gp_Pnt2d>& intersections, double& theMid, double& theWid )
{
double umin = std::numeric_limits<double>::max(),
umax = -umin;
size_t n = intersections.size();
if( n <= 1 )
- return 0;
+ return false;
for( size_t i = 0; i < n; i++ )
{
if( u>umax )
umax = u;
}
- return umax-umin;
+ theMid = ( umin+umax )/2;
+ theWid = umax-umin;
+ return true;
}
void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& theProfile,
if( intersections.size() >= 2 )
{
- double u_mid = CalcGC( intersections );
+ double u_mid, u_wid;
+ if( !CalcMidWidth( intersections, u_mid, u_wid ) )
+ continue;
+
PointUZ p_mid;
p_mid.U = u_mid;
p_mid.Z = z;
theMidPointCurve.push_back( p_mid );
- double u_wid = CalcWidth( intersections );
PointUZ p_wid;
p_wid.U = u_wid;
p_wid.Z = z;
if( isAddSecond )
theInterpolation.push_back( theCurveB );
}
-
+#include <BRepLib_MakeEdge2d.hxx>
void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
AltitudePoints& thePoints,
Bank* theLeft, Bank* theRight, double dz )
{
Geom2dAdaptor_Curve anAdaptor( theHydraulicAxis );
+ TopoDS_Edge E2d = BRepLib_MakeEdge2d(theHydraulicAxis).Edge();
GCPnts_AbscissaPoint ap( anAdaptor, theMidCurve.Xcurv(), anAdaptor.FirstParameter() );
double aParam = ap.Parameter();
anAdaptor.D1( aParam, point, tangent );
profile_dir.SetCoord( tangent.Y(), -tangent.X() );
profile_dir.Normalize();
- gp_Dir tangent_n( tangent.X(), tangent.Y(), dz );
-
+ gp_Dir tangent_n( tangent.X(), tangent.Y(), -dz );
+ //gp_Dir tangent_n( 0, 0, 1 );
size_t n = theMidCurve.size();
double min_param = 1E+15;
double max_param = -1E+15;
double param1 = theMidCurve[i].U - theWidthCurve[i].U / 2;
double param2 = theMidCurve[i].U + theWidthCurve[i].U / 2;
- gp_Pnt2d p1 = point.Translated( param1 * profile_dir / 2 );
- gp_Pnt2d p2 = point.Translated( param2 * profile_dir / 2 );
+ gp_Pnt2d p1 = point.Translated( param1 * profile_dir);
+ gp_Pnt2d p2 = point.Translated( param2 * profile_dir);
double z = theMidCurve[i].Z;
if( theLeft )
{
- gp_Pnt2d left2d = point.Translated( min_param * profile_dir / 2 );
+ gp_Pnt2d left2d = point/*.Translated( min_param * profile_dir )*/;
gp_Pnt left( left2d.X(), left2d.Y(), z1 );
theLeft->push_back( left, tangent_n );
}
if( theRight )
{
- gp_Pnt2d right2d = point.Translated( max_param * profile_dir / 2 );
+ gp_Pnt2d right2d = point.Translated( max_param * profile_dir );
gp_Pnt right( right2d.X(), right2d.Y(), z2 );
theRight->push_back( right, tangent_n );
}
return b;
}
+#include <BRepLib_MakeWire.hxx>
+
HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate
( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
const Handle_HYDROData_Profile& theProfileA,
for( size_t i=0; i<p; i++ )
CurveTo3D( theHydraulicAxis, mid[i], wid[i], points, theLeft, theRight, dz );
+ BRepLib_MakeWire WM;
+ for (int i =0; i < theLeft->myPoints.size() - 1; i++)
+ WM.Add(BRepLib_MakeEdge(theLeft->myPoints[i], theLeft->myPoints[i+1]).Edge());
+ TopoDS_Wire W = WM.Wire();
return points;
}
for( size_t i=0, n1=n-1; i<n1; i++ )
{
double aDistance = distances[i+1]-distances[i];
- aNbStepsComplete += ( int(aDistance/theSpatialStep) + 1 );
+ aNbStepsComplete += ( int(aDistance/theSpatialStep) /*+ 1*/ );
}
if( theLeft )
theLeft->reserve( aNbStepsComplete );
for( size_t i=0, n1=n-1; i<n1; i++ )
{
double aDistance = distances[i+1]-distances[i];
- int aNbSteps = int(aDistance/theSpatialStep) + 1;
+ int aNbSteps = int(aDistance/theSpatialStep) /*+ 1*/;
bool isAddSecond = i==n1-1;
AltitudePoints local_points = Interpolate( aHydraulicAxis, theProfiles[i], distances[i],
if( profiles.Length() < 2 )
return false;
- TopTools_ListOfShape profiles3d;
+ std::vector<TopoDS_Wire> profiles3d;
+ profiles3d.reserve(profiles.Length());
// Pre-processing
HYDROData_SequenceOfObjects::Iterator anIter( profiles );
continue;
const TopoDS_Shape& aProfileShape = aProfile->GetShape3D();
- profiles3d.Append( aProfileShape );
+ //TopExp_Explorer exp(aProfileShape, TopAbs_EDGE);
+ profiles3d.push_back( TopoDS::Wire(aProfileShape) );
}
TopoDS_Edge aLeftBank, aRightBank;
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Plane.hxx>
#include <BRepTools.hxx>
-static void ProjEdgeOnPlane(const TopoDS_Edge& inpEdge, const Handle_Geom_Plane& RefPlane, TopoDS_Edge& outSh, TopoDS_Vertex V1, TopoDS_Vertex V2)
+#include <BRepTools_WireExplorer.hxx>
+static void ProjEdgeOnPlane(const TopoDS_Wire& inpWire, const Handle_Geom_Plane& RefPlane, TopoDS_Wire& outWire, TopoDS_Vertex V1, TopoDS_Vertex V2)
{
- double f, l;
- Handle(Geom_Curve) C3d = BRep_Tool::Curve(inpEdge, f, l);
- Handle(Geom_Curve) ProjectedCurve = GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d, f, l), RefPlane, RefPlane->Position().Direction(), Standard_True);
- if (V1.IsNull() || V2.IsNull())
- outSh = BRepLib_MakeEdge(ProjectedCurve); //create new vertices
- else
- outSh = BRepLib_MakeEdge(ProjectedCurve, V1, V2);
+ BRepTools_WireExplorer ex(inpWire);
+ BRepLib_MakeWire WM;
+ for (;ex.More();ex.Next())
+ {
+ const TopoDS_Edge& CE = ex.Current();
+ 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
+ }
+ outWire = WM.Wire();
+ //if (V1.IsNull() || V2.IsNull())
+ // outSh = BRepLib_MakeEdge(ProjectedCurve); //create new vertices
+ //else
+ // outSh = BRepLib_MakeEdge(ProjectedCurve, V1, V2);
}
bool HYDROData_Stream::CreatePresentations( const TopoDS_Edge& theLeftBank,
const TopoDS_Edge& theRightBank,
- const std::vector<TopoDS_Edge>& theProfiles3d,
+ const std::vector<TopoDS_Wire>& theProfiles3d,
PrsDefinition& thePrs )
{
thePrs.myLeftBank = theLeftBank;
thePrs.myPrs3D = aCmp; //3d pres
+ /*Handle_Geom_Plane RefPlane = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1));
+ TopoDS_Vertex V1, V2;
+ TopoDS_Wire W;
+ ProjEdgeOnPlane(theProfiles3d[0], RefPlane, W, V1, V2);*/
- Handle_Geom_Plane RefPlane = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1));
+ /* Handle_Geom_Plane RefPlane = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1));
std::vector<TopoDS_Edge> internProf;
internProf.reserve(theProfiles3d.size() - 2);
WM.Add(internProf[i]);
TopoDS_Face outF = BRepLib_MakeFace(RefPlane, WM.Wire()).Face();
- thePrs.myPrs2D = outF;
+ thePrs.myPrs2D = outF;*/
return true;
/*if ( theArrayOfFPnt.IsNull() || theArrayOfLPnt.IsNull() || theArrOfProfiles.IsNull() ) {