{
SetDouble( DataTag_SpatialStep, theSpatialStep );
}
+#include <BRepLib_MakeEdge.hxx>
+#include <BRepLib_MakeWire.hxx>
+//#include <BRepLib_MakeFace.hxx>
+#include <BRep_Builder.hxx>
+#include <GeomProjLib.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <Geom_Plane.hxx>
+#include <BRepTools_WireExplorer.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+void HYDROData_DTM::PointToWire(const AltitudePoints& pnts, TopoDS_Wire& W )
+{
+ BRepLib_MakeWire WM;
+ for (int i =0; i < pnts.size() - 1; i++)
+ {
+ gp_Pnt p1(pnts[i].X, pnts[i].Y, pnts[i].Z);
+ gp_Pnt p2(pnts[i+1].X, pnts[i+1].Y, pnts[i+1].Z);
+ WM.Add(BRepLib_MakeEdge(p1, p2).Edge());
+ }
+ W = WM.Wire();
+}
+
+static void ProjWireOnPlane(const TopoDS_Wire& inpWire, const Handle_Geom_Plane& RefPlane, TopoDS_Wire& outWire)
+{
+ BRepTools_WireExplorer ex(TopoDS::Wire(inpWire.Oriented(TopAbs_FORWARD)));
+ 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();
+ outWire.Orientation(inpWire.Orientation()); //take from the original wire
+}
+
void HYDROData_DTM::Update()
{
if( ddz>EPS && step>EPS )
points = Interpolate( profiles, ddz, step, left, right, main_profiles );
- SetAltitudePoints( points );
- //SetTopShape(); //2d
- //SetShape3D(); //3d
-}
+ BRep_Builder BB;
+ TopoDS_Compound cmp;
+ BB.MakeCompound(cmp);
+ TopoDS_Wire LWire, RWire;
+ PointToWire(left, LWire);
+ PointToWire(right, RWire);
+ BB.Add(cmp, LWire.Oriented(TopAbs_FORWARD));
+
+ for (int k = 0; k < main_profiles.size(); k++)
+ {
+ TopoDS_Wire W;
+ PointToWire(main_profiles[k], W);
+ TopAbs_Orientation Ori = TopAbs_INTERNAL;
+ if (k == 0 || k == main_profiles.size() - 1)
+ Ori = TopAbs_FORWARD;
+ BB.Add(cmp, W.Oriented(Ori));
+ }
+
+ BB.Add(cmp, RWire.Oriented(TopAbs_FORWARD));
+ //in this order (left + profiles + right)
+ //otherwise the projected wire will be non-manifold!!!
+ //cmp = 3d pres
+ Handle_Geom_Plane refpl = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1));
+ BRepLib_MakeWire WM;
+ TopoDS_Iterator it(cmp);
+ TopTools_IndexedMapOfShape IntW;
+ for (;it.More(); it.Next())
+ {
+ const TopoDS_Wire& W = TopoDS::Wire(it.Value());
+ if (W.Orientation() != TopAbs_INTERNAL)
+ WM.Add(W);
+ else
+ IntW.Add(W);
+ }
+ TopoDS_Wire outW;
+ ProjWireOnPlane(WM.Wire(), refpl, outW);
+ BRepBuilderAPI_MakeFace mf(refpl, outW); //check inside is true by def
+ TopoDS_Face outF = mf.Face();
+ ///!!! 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.
+ for (int i = 1; i <= IntW.Extent(); i++)
+ {
+ TopoDS_Wire outIW;
+ const TopoDS_Wire& W = TopoDS::Wire(IntW(i));
+ ProjWireOnPlane(W, refpl, outIW);
+ BB.Add(outF, outIW);
+ }
+ //outF == 2d pres
+ SetAltitudePoints( points );
+ //SetTopShape(); //2d
+ //this->SetShape(cmp); //3d
+}
}
}
}
-#include <GeomProjLib.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <Geom_Plane.hxx>
-#include <BRepTools.hxx>
-#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)
-{
- 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 std::vector<TopoDS_Wire>& theProfiles3d,
PrsDefinition& thePrs )
{
- thePrs.myLeftBank = theLeftBank;
- thePrs.myRightBank = theRightBank;
-
- BRep_Builder aBB;
- TopoDS_Compound aCmp;
- aBB.MakeCompound(aCmp);
- for (size_t i = 0; i < theProfiles3d.size(); i++ )
- aBB.Add(aCmp, theProfiles3d[i]);
-
- aBB.Add(aCmp, theLeftBank);
- aBB.Add(aCmp, theRightBank);
-
- thePrs.myPrs3D = aCmp; //3d pres
-
+ //thePrs.myLeftBank = theLeftBank;
+ //thePrs.myRightBank = theRightBank;
+ //
+ //BRep_Builder aBB;
+ //TopoDS_Compound aCmp;
+ //aBB.MakeCompound(aCmp);
+ //for (size_t i = 0; i < theProfiles3d.size(); i++ )
+ // aBB.Add(aCmp, theProfiles3d[i]);
+ //
+ //aBB.Add(aCmp, theLeftBank);
+ //aBB.Add(aCmp, theRightBank);
+ //
+ //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;