#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <BRep_Builder.hxx>
+
#include <Precision.hxx>
#include <Prs3d_ShadingAspect.hxx>
Handle(HYDROData_ImmersibleZone) aZoneObj =
Handle(HYDROData_ImmersibleZone)::DownCast( myObject );
+ TopoDS_Shape aZoneShape = aZoneObj->GetTopShape();
+ if ( !aZoneShape.IsNull() ) {
+ if ( aZoneShape.ShapeType() == TopAbs_FACE ) {
+ TopoDS_Face aZoneFace = TopoDS::Face( aZoneShape );
+ setFace( aZoneFace, false, false );
+ } else {
+ myTopoShape = aZoneShape;
+ myDisplayMode = myTextureFileName.isEmpty() ? AIS_Shaded : AIS_Shaded+2;
+
+ buildShape();
+ updateShape( false, false );
+ }
+ }
+
QColor aFillingColor = aZoneObj->GetFillingColor();
QColor aBorderColor = aZoneObj->GetBorderColor();
- TopoDS_Face aZoneFace = TopoDS::Face( aZoneObj->GetTopShape() );
setFillingColor( aFillingColor, false, false );
setBorderColor( aBorderColor, false, false );
- setFace( aZoneFace, false, false );
}
else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline) ) )
{
Handle(HYDROData_Polyline) aPolyline =
Handle(HYDROData_Polyline)::DownCast( myObject );
- TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolyline->GetTopShape() );
+ TopoDS_Shape aPolylineShape = aPolyline->GetTopShape();
+
+ if ( !aPolylineShape.IsNull() ) {
+ if ( aPolylineShape.ShapeType() == TopAbs_WIRE ) {
+ TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolylineShape );
+ setWire( aPolylineWire, false, false );
+ } else {
+ myTopoShape = aPolylineShape;
+ myDisplayMode = AIS_WireFrame;
- setWire( aPolylineWire, false, false );
+ buildShape();
+ updateShape( false, false );
+ }
+ }
}
else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Zone) ) )
{
myTopoShape = anObstacle->GetShape3D();
myDisplayMode = AIS_Shaded;
- //TODO colors should be defined in another way
- setFillingColor( Qt::green, false, false );
+ QColor aFillingColor = anObstacle->GetFillingColor();
+ QColor aBorderColor = anObstacle->GetBorderColor();
+
+ setFillingColor( aFillingColor, false, false );
+ setBorderColor( aBorderColor, false, false );
buildShape();
updateShape( false, false );
updateShape( theToDisplay, theIsUpdateViewer );
}
+void HYDROGUI_Shape::setFaces( const TopoDS_Compound& theWires,
+ const bool theToDisplay,
+ const bool theIsUpdateViewer )
+{
+ TopExp_Explorer anExp( theWires, TopAbs_WIRE );
+ TopoDS_Compound aCompound;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound( aCompound );
+
+ for ( ; anExp.More(); anExp.Next() ) {
+ TopoDS_Wire aWire = TopoDS::Wire( anExp.Current() );
+ if ( aWire.IsNull() ) {
+ continue;
+ }
+
+ BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
+ aMakeFace.Build();
+ if( aMakeFace.IsDone() ) {
+ aBuilder.Add( aCompound, aMakeFace.Face() );
+ }
+ }
+
+ myTopoShape = aCompound;
+ myDisplayMode = AIS_Shaded;
+
+ buildShape();
+ updateShape( theToDisplay, theIsUpdateViewer );
+}
+
void HYDROGUI_Shape::setFace( const TopoDS_Wire& theWire,
const bool theToDisplay,
const bool theIsUpdateViewer )
updateShape( theToDisplay, theIsUpdateViewer );
}
+void HYDROGUI_Shape::setShape( const TopoDS_Shape& theShape,
+ const bool theToDisplay,
+ const bool theIsUpdateViewer )
+{
+ myTopoShape = theShape;
+ myDisplayMode = AIS_Shaded;
+
+ buildShape();
+ updateShape( theToDisplay, theIsUpdateViewer );
+}
+
void HYDROGUI_Shape::setFillingColor( const QColor& theColor,
const bool theToDisplay,
const bool theIsUpdateViewer )