#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <TopExp_Explorer.hxx>
+#include <TopExp.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
#define CALCULATION_REGIONS_PREF GetName() + "_Reg"
#define CALCULATION_ZONES_PREF GetName() + "_Zone"
{
TopoDS_Shell aShell;
+ TopTools_ListOfShape aFacesList;
+
// Make shell containing all region shapes
BRepBuilderAPI_Sewing aSewing( Precision::Confusion()*10.0 );
TopoDS_Shape aRegionShape = aRegion->GetShape();
if( !aRegionShape.IsNull() ) {
- aSewing.Add( aRegionShape );
+ TopExp_Explorer anExp( aRegionShape, TopAbs_FACE );
+ if ( anExp.More() ) {
+ for ( ; anExp.More(); anExp.Next() ) {
+ TopoDS_Face aFace = TopoDS::Face( anExp.Current() );
+ if ( !aFace.IsNull() ) {
+ aFacesList.Append( aFace );
+ aSewing.Add( aFace );
+ }
+ }
+ } else {
+ if ( aRegionShape.ShapeType() == TopAbs_FACE ) {
+ aFacesList.Append( aRegionShape );
+ }
+ aSewing.Add( aRegionShape );
+ }
}
} // regions iterator
}
}
+ if ( !aShell.IsNull() ) {
+ TopTools_IndexedMapOfShape aMapOfFaces;
+ TopExp::MapShapes( aShell, TopAbs_FACE, aMapOfFaces );
+ if ( aMapOfFaces.Extent() != aFacesList.Extent() ) {
+ aShell.Nullify();
+ BRep_Builder aBuilder;
+ aBuilder.MakeShell( aShell );
+
+ TopTools_ListIteratorOfListOfShape anIter( aFacesList );
+ for ( ; anIter.More(); anIter.Next() ) {
+ TopoDS_Face aFace = TopoDS::Face( anIter.Value() );
+ aBuilder.Add( aShell, aFace );
+ }
+ }
+ }
+
/* TODO: old version
// Make shell
BRep_Builder aBuilder;
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <BRep_Builder.hxx>
#include <QColor>
#include <QStringList>
TopoDS_Shape HYDROData_ImmersibleZone::GetTopShape() const
{
+ TopoDS_Shape aResShape = TopoDS_Face();
+
Handle(HYDROData_Polyline) aPolyline = GetPolyline();
if( !aPolyline.IsNull() )
{
- TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolyline->GetTopShape() );
- if( !aPolylineWire.IsNull() )
- {
- BRepBuilderAPI_MakeFace aMakeFace( aPolylineWire, Standard_True );
+ TopoDS_Shape aPolylineShape = aPolyline->GetTopShape();
+ TopTools_ListOfShape aWiresList;
+
+ TopExp_Explorer anExp( aPolylineShape, TopAbs_WIRE );
+ if ( !anExp.More() ) {
+ TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolylineShape );
+ if ( !aPolylineWire.IsNull() ) {
+ BRepBuilderAPI_MakeFace aMakeFace( aPolylineWire, Standard_True );
+ aMakeFace.Build();
+ if( aMakeFace.IsDone() ) {
+ return aMakeFace.Face();
+ }
+ }
+ } else {
+ for ( ; anExp.More(); anExp.Next() ) {
+ TopoDS_Wire aWire = TopoDS::Wire( anExp.Current() );
+ aWiresList.Append( aWire );
+ }
+ }
+
+ TopoDS_Compound aCompound;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound( aCompound );
+
+ TopTools_ListIteratorOfListOfShape anIter( aWiresList );
+ for ( ; anIter.More(); anIter.Next() ) {
+ TopoDS_Wire aWire = TopoDS::Wire( anIter.Value() );
+ if ( aWire.IsNull() ) {
+ continue;
+ }
+
+ BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
aMakeFace.Build();
- if( aMakeFace.IsDone() )
- return aMakeFace.Face();
+ if( aMakeFace.IsDone() ) {
+ aBuilder.Add( aCompound, aMakeFace.Face() );
+ }
}
+
+ aResShape = aCompound;
}
- return TopoDS_Face();
+
+ return aResShape;
}
TopoDS_Shape HYDROData_ImmersibleZone::GetShape3D() const
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
+#include <BRep_Builder.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <QStringList>
double aZValue = ZValue();
+ TopTools_ListOfShape aSectionWiresList;
+
int aSectionCount = theSections.size();
for( int aSectionId = 0; aSectionId < aSectionCount; aSectionId++ )
{
aMakeSectionWire.Add( anEdge );
}
TopoDS_Wire aSectionWire = aMakeSectionWire.Wire();
+ aSectionWiresList.Append( aSectionWire );
aMakeWire.Add( aSectionWire );
}
}
- TopoDS_Shape aShape = aMakeWire.Shape();
+ TopoDS_Shape aShape;
+ if ( aMakeWire.IsDone() ) {
+ aShape = aMakeWire.Shape();
+ } else {
+ // build compound
+ TopoDS_Compound aCompound;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound( aCompound );
+ TopTools_ListIteratorOfListOfShape anIter( aSectionWiresList );
+ for ( ; anIter.More(); anIter.Next() ) {
+ aBuilder.Add( aCompound, anIter.Value() );
+ }
+ aShape = aCompound;
+ }
+
SetTopShape( aShape );
}
#include <HYDROData_CalculationCase.h>
#include <GeometryGUI.h>
+#include <GEOMBase.h>
#include <SalomeApp_Study.h>
// Puplish the GEOM object
if ( !aGeomObj->_is_nil() ) {
- QString aName = tr( "OBJ_PREFIX" ) + aCalculation->GetName();
+ QString aName = GEOMBase::GetDefaultName( tr( "OBJ_PREFIX" ) + aCalculation->GetName() );
SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
SALOMEDS::SObject_var aResultSO =
return;
TopoDS_Wire aWire;
+ TopoDS_Shape aShape;
Handle(HYDROData_Polyline) aPolyline = Handle(HYDROData_Polyline)::DownCast(
HYDROGUI_Tool::FindObjectByName( module(), thePolylineName, KIND_POLYLINE ) );
if ( !aPolyline.IsNull() )
{
- aWire = TopoDS::Wire( aPolyline->GetTopShape() );
+ aShape = aPolyline->GetTopShape();
+ if ( aShape.ShapeType() == TopAbs_WIRE ) {
+ aWire = TopoDS::Wire( aShape );
+ }
}
LightApp_Application* anApp = module()->getApp();
myPreviewPrs->setFillingColor( aFillingColor, false, false );
myPreviewPrs->setBorderColor( aBorderColor, false, false );
- myPreviewPrs->setFace( aWire );
+ if ( !aWire.IsNull() ) {
+ myPreviewPrs->setFace( aWire );
+ } else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND ) {
+ TopoDS_Compound aCompound = TopoDS::Compound( aShape );
+ if ( !aCompound.IsNull() ) {
+ myPreviewPrs->setFaces( aCompound );
+ }
+ }
}
void HYDROGUI_ImmersibleZoneOp::closePreview()
#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) ) )
{
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 )
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
+#include <TopoDS_Compound.hxx>
class HYDROGUI_Shape
{
const bool theToDisplay = true,
const bool theIsUpdateViewer = true );
+ virtual void setFaces( const TopoDS_Compound& theWires,
+ const bool theToDisplay = true,
+ const bool theIsUpdateViewer = true );
+
virtual void setFace( const TopoDS_Wire& theWire,
const bool theToDisplay = true,
const bool theIsUpdateViewer = true );
const bool theToDisplay = true,
const bool theIsUpdateViewer = true );
+ virtual void setShape( const TopoDS_Shape& theShape,
+ const bool theToDisplay = true,
+ const bool theIsUpdateViewer = true );
+
virtual void setFillingColor( const QColor& theColor,
const bool theToDisplay = true,
const bool theIsUpdateViewer = true );