Salome HOME
Merge from BR_new_bop4 (porting to new OCCT BOP) 13/09/2013
[modules/geom.git] / src / GEOMImpl / GEOMImpl_FillingDriver.cxx
index 1907c7e539f0188b48d104541fb746a51d96bbc2..06a3f894b98b4f631a5e13bf575298ce73b492ad 100644 (file)
@@ -135,91 +135,16 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const
   for (; It.More(); It.Next()) {
     Scurrent = It.Value();
     if (Scurrent.ShapeType() != TopAbs_EDGE) {
-      Handle(Geom_BSplineCurve) newC;
-      if (Scurrent.ShapeType() == TopAbs_WIRE) {
-        TColgp_SequenceOfPnt PntSeq;
-        // collect points
-        for (Ex.Init(Scurrent, TopAbs_EDGE); Ex.More(); Ex.Next()) {
-          TopoDS_Edge E = TopoDS::Edge(Ex.Current());
-          if (BRep_Tool::Degenerated(E)) continue;
-          C = BRep_Tool::Curve(E, First, Last);
-          if( E.Orientation() == TopAbs_REVERSED ) {
-            C->Reverse();
-          }
-          Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(C);
-          while( !tc.IsNull() ) {
-            C = tc->BasisCurve();
-            tc = Handle(Geom_TrimmedCurve)::DownCast(C);
-          }
-          int nbp = 10;
-          if( C->IsKind(STANDARD_TYPE(Geom_Line)) ) {
-            nbp = 4;
-          }
-          else if( C->IsKind(STANDARD_TYPE(Geom_Circle)) || 
-                   C->IsKind(STANDARD_TYPE(Geom_Ellipse)) ) {
-            nbp = (int)25*fabs(Last-First)/(2.*M_PI);
-          }
-          else if( C->IsKind(STANDARD_TYPE(Geom_BezierCurve)) ) {
-            Handle(Geom_BezierCurve) C3d = Handle(Geom_BezierCurve)::DownCast(C);
-            nbp = C3d->NbPoles();
-          }
-          else if( C->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) ) {
-            Handle(Geom_BSplineCurve) C3d = Handle(Geom_BSplineCurve)::DownCast(C);
-            nbp = C3d->NbPoles();
-          }
-          else {
-          }
-          if( nbp<4 ) nbp = 4;
-          double dp = (Last-First)/(nbp-1);
-          for(int i=1; i<nbp; i++) {
-            gp_Pnt P;
-            C->D0(First+dp*(i-1),P);
-            PntSeq.Append(P);
-          }
-        }
-        // add last point
-        gp_Pnt P;
-        C->D0(Last,P);
-        PntSeq.Append(P);
-        // create BSpline 
-        if(PntSeq.Length()>1) {
-          TColgp_Array1OfPnt Pnts(1,PntSeq.Length());
-          // check orientation of wire
-          if( Scurrent.Orientation() == TopAbs_REVERSED ) {
-            for(int i=1; i<=PntSeq.Length(); i++) {
-              Pnts.SetValue(PntSeq.Length()-i+1,PntSeq.Value(i));
-            }
-          }
-          else {
-            for(int i=1; i<=PntSeq.Length(); i++) {
-              Pnts.SetValue(i,PntSeq.Value(i));
-            }
-          }
-          GeomAPI_PointsToBSpline PTB (Pnts);
-          newC = Handle(Geom_BSplineCurve)::DownCast(PTB.Curve());
-          // set periodic flag if curve is closed
-          //if( newC->IsClosed() ) {
-          //  newC->SetPeriodic();
-          //}
-          // create edge
-          double fp = newC->FirstParameter();
-          double lp = newC->FirstParameter();
-          gp_Pnt PF,PL;
-          newC->D0(fp,PF);
-          newC->D0(lp,PL);
-          TopoDS_Vertex VF,VL;
-          B.MakeVertex(VF,PF,1.e-7);
-          B.MakeVertex(VL,PL,1.e-7);
-          TopoDS_Edge newE;
-          B.MakeEdge(newE,newC,1.e-7);
-          B.Add(newE,VF);
-          B.Add(newE,VL.Reversed());
-          Scurrent = newE;
-        }
+      TopoDS_Edge NewEdge;
+      if (Scurrent.ShapeType() == TopAbs_WIRE)
+      {
+        const TopoDS_Wire& CurWire = TopoDS::Wire(Scurrent);
+        NewEdge = BRepAlgo::ConcatenateWireC0(CurWire);
       }
-      if (newC.IsNull()) {
+      if (NewEdge.IsNull()) {
         Standard_ConstructionError::Raise("The argument compound must contain only edges");
       }
+      Scurrent = NewEdge;
     }
     B.Add(aComp,Scurrent);
   }
@@ -386,44 +311,47 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const
   return 1;
 }
 
+//================================================================================
+/*!
+ * \brief Returns a name of creation operation and names and values of creation parameters
+ */
+//================================================================================
 
-//=======================================================================
-//function :  GEOMImpl_FillingDriver_Type_
-//purpose  :
-//=======================================================================
-Standard_EXPORT Handle_Standard_Type& GEOMImpl_FillingDriver_Type_()
-{
-  static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
-  if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
-  static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
-  if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
-  static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
-  if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
-
-  static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
-  static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_FillingDriver",
-                                                         sizeof(GEOMImpl_FillingDriver),
-                                                         1,
-                                                         (Standard_Address)_Ancestors,
-                                                         (Standard_Address)NULL);
-
-  return _aType;
-}
-
-//=======================================================================
-//function : DownCast
-//purpose  :
-//=======================================================================
-const Handle(GEOMImpl_FillingDriver) Handle(GEOMImpl_FillingDriver)::DownCast
-                                 (const Handle(Standard_Transient)& AnObject)
+bool GEOMImpl_FillingDriver::
+GetCreationInformation(std::string&             theOperationName,
+                       std::vector<GEOM_Param>& theParams)
 {
-  Handle(GEOMImpl_FillingDriver) _anOtherObject;
-
-  if (!AnObject.IsNull()) {
-     if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_FillingDriver))) {
-       _anOtherObject = Handle(GEOMImpl_FillingDriver)((Handle(GEOMImpl_FillingDriver)&)AnObject);
-     }
+  if (Label().IsNull()) return 0;
+  Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
+
+  GEOMImpl_IFilling aCI( function );
+  Standard_Integer aType = function->GetType();
+
+  theOperationName = "FILLING";
+
+  switch ( aType ) {
+  case BASIC_FILLING:
+  {
+    AddParam( theParams, "Input compound", aCI.GetShape() );
+    AddParam( theParams, "Method", aCI.GetMethod() );
+    const char* method[3] =
+      { "Standard", "Use edges orientation", "Correct edges orientation" };
+    if ( 0 <= aCI.GetMethod() && aCI.GetMethod() < 3 )
+      theParams[1] << " = " << method[ aCI.GetMethod() ];
+    AddParam( theParams, "Min deg", aCI.GetMinDeg() );
+    AddParam( theParams, "Max deg", aCI.GetMaxDeg() );
+    AddParam( theParams, "Nb. Iter", aCI.GetNbIter() );
+    AddParam( theParams, "Tol. 2D", aCI.GetTol2D() );
+    AddParam( theParams, "Tol. 3D", aCI.GetTol3D() );
+    AddParam( theParams, "Approximation", aCI.GetApprox() );
+    break;
+  }
+  default:
+    return false;
   }
 
-  return _anOtherObject;
+  return true;
 }
+
+IMPLEMENT_STANDARD_HANDLE (GEOMImpl_FillingDriver,GEOM_BaseDriver);
+IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_FillingDriver,GEOM_BaseDriver);