Salome HOME
Merge remote branch 'origin/gdd/translations'
authorvsr <vsr@opencascade.com>
Thu, 12 Feb 2015 15:51:15 +0000 (18:51 +0300)
committervsr <vsr@opencascade.com>
Thu, 12 Feb 2015 15:51:15 +0000 (18:51 +0300)
src/GEOMImpl/GEOMImpl_FilletDriver.cxx
src/GEOMUtils/GEOMUtils.cxx
src/GEOMUtils/GEOMUtils.hxx
src/STLPlugin/STLPlugin_ExportDriver.cxx
src/XAOPlugin/XAOPlugin_IOperations.cxx

index f49fb08f71afebef52e1bd641b922379499a7c8a..034d2f274d8e56ffad30d3d32987ab8a16740f4b 100644 (file)
@@ -130,7 +130,7 @@ Standard_Integer GEOMImpl_FilletDriver::Execute(TFunction_Logbook& log) const
   if (!fill.IsDone()) {
     StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius");
   }
-  aShape = fill.Shape();
+  aShape = GEOMUtils::ReduceCompound( fill.Shape() );
 
   if (aShape.IsNull()) return 0;
 
index 3087c82d394f439750cf1cc89d7f2a15e2b18426..6d9643f0ce90eed0abbdc957fe29c36bc4cdd35b 100644 (file)
@@ -1174,3 +1174,22 @@ bool GEOMUtils::Write( const TopoDS_Shape& shape, const char* fileName )
 {
   return BRepTools::Write( shape, fileName );
 }
+
+TopoDS_Shape GEOMUtils::ReduceCompound( const TopoDS_Shape& shape )
+{
+  TopoDS_Shape result = shape;
+
+  if ( shape.ShapeType() == TopAbs_COMPOUND ||
+       shape.ShapeType() == TopAbs_COMPSOLID ) {
+
+    TopTools_ListOfShape l;
+    
+    TopoDS_Iterator it ( shape );
+    for ( ; it.More(); it.Next() )
+      l.Append( it.Value() );
+    if ( l.Extent() == 1 && l.First() != shape )
+      result = ReduceCompound( l.First() );
+  }
+  
+  return result;
+}
index 2a35dceda7709b15739cf830e138a98821fad4c6..b673ea8078d6edd9e7374919fcce25e14058178f 100644 (file)
@@ -300,6 +300,18 @@ namespace GEOMUtils
    */
   Standard_EXPORT bool Write( const TopoDS_Shape& shape,
                               const char* fileName );
+  
+  /*!
+   * \brief Extract single SOLID from COMPSOLID or COMPOUND.
+   *
+   * If the argument shape is a COMPUND or COMPSOLID and there's
+   * only single simple-shape type inside, this sub-shape is returned as a result;
+   * otherwise, the shape is not changed.
+   *
+   * \param shape compound or compsolid being processed.
+   * \retval TopoDS_Shape resulting shape
+   */
+  Standard_EXPORT TopoDS_Shape ReduceCompound( const TopoDS_Shape& shape );
 };
 
 #endif
index 7d02d6f8fad6adc31594437fc22b97f214dc6a69..41130de41d2c1ea4cb474c131291d7849d21d384 100644 (file)
@@ -24,6 +24,7 @@
 // KERNEL includes
 #include <utilities.h>
 #include <Basics_Utils.hxx>
+#include <Basics_OCCTVersion.hxx>
 
 // GEOM includes
 #include "GEOM_Function.hxx"
 #include <BRepBuilderAPI_Copy.hxx>
 #include <StlAPI_Writer.hxx>
 #include <TopoDS_Shape.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepTools.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
+
+#define MAX2(X, Y)      ( Abs(X) > Abs(Y) ? Abs(X) : Abs(Y) )
+#define MAX3(X, Y, Z)   ( MAX2 ( MAX2(X, Y) , Z ) )
 
 //=======================================================================
 //function : GetID
@@ -84,15 +92,31 @@ Standard_Integer STLPlugin_ExportDriver::Execute( TFunction_Logbook& log ) const
   try
   {
     StlAPI_Writer aWriter;
+    // copy source shape
+    BRepBuilderAPI_Copy aCopy( aShape, Standard_False );
+    TopoDS_Shape aCopyShape = aCopy.Shape();
+    // ASCII mode
+    aWriter.ASCIIMode() = anIsASCII;
+#if OCC_VERSION_LARGE > 0x06080000
+    if ( anIsRelative ) {
+      Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+      Bnd_Box bndBox;
+      BRepBndLib::Add( aShape, bndBox );
+      bndBox.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+      aDeflection = MAX3( aXmax-aXmin, aYmax-aYmin, aZmax-aZmin ) * aDeflection;
+    }
+    //Compute triangulation
+    BRepTools::Clean( aCopyShape );
+    BRepMesh_IncrementalMesh aMesh( aCopyShape, aDeflection );
+#else
     // set relative mode on false for using custom deflection coefficient
     aWriter.RelativeMode( ) = anIsRelative;
-    aWriter.ASCIIMode() = anIsASCII;
     if( anIsRelative )
       aWriter.SetCoefficient( aDeflection );
     else
       aWriter.SetDeflection( aDeflection );
-    BRepBuilderAPI_Copy aCopy( aShape, Standard_False );
-    aWriter.Write( aCopy.Shape(), aFileName.ToCString() );
+#endif
+    aWriter.Write( aCopyShape, aFileName.ToCString() );
     log.SetTouched( Label() );
     return 1;
   }
index 96949ced7b2a0912b0f2f5ae0bec5178f0eb5b31..d491cad2b49d02911a741359797061cc3ac0f928 100644 (file)
@@ -258,7 +258,7 @@ void XAOPlugin_IOperations::exportFields( std::list<Handle(GEOM_Field)> fieldLis
 
 void XAOPlugin_IOperations::exportSubshapes( const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry )
 {
-  Handle(TColStd_HSequenceOfTransient) subObjects = myShapesOperations->GetExistingSubObjects( shape, false );
+  Handle(TColStd_HSequenceOfTransient) subObjects = myShapesOperations->GetExistingSubObjects( shape, GEOMImpl_IShapesOperations::SubShapes );
   int nbSubObjects = subObjects->Length();
   // set the names of the sub shapes
   for (int i = 1; i <= nbSubObjects; i++)