]> OCCT Git - occt-copy.git/commitdiff
0029270: Added possibility to load in the STEP model a few step files. CR29270
authorgka <gka@opencascade.com>
Wed, 2 Aug 2017 08:36:05 +0000 (11:36 +0300)
committergka <gka@opencascade.com>
Fri, 27 Oct 2017 14:08:42 +0000 (17:08 +0300)
if in the method  XSControl_Reader::SetWS(const Handle(XSControl_WorkSession)& WS,const Standard_Boolean scratch) flag scratch is equal to false then entities from loaded step files were added in the existing STEP model.

src/IFSelect/IFSelect_WorkSession.cxx
src/RWStepVisual/RWStepVisual_RWPresentationLayerAssignment.cxx
src/StepData/StepData_StepModel.cxx
src/StepData/StepData_StepReaderData.cxx
src/StepSelect/StepSelect_WorkLibrary.cxx
src/StepVisual/StepVisual_PresentationLayerAssignment.cxx

index 611bb309115721dc59b46575fede1e93a4eebaf6..b9416b4954587781139de42b1578026a5610c53d 100644 (file)
@@ -212,7 +212,7 @@ IFSelect_ReturnStatus  IFSelect_WorkSession::ReadFile
 {
   if (thelibrary.IsNull()) return IFSelect_RetVoid;
   if (theprotocol.IsNull()) return IFSelect_RetVoid;
-  Handle(Interface_InterfaceModel) model;
+  Handle(Interface_InterfaceModel) model =myModel;
   IFSelect_ReturnStatus status = IFSelect_RetVoid;
   try {
     OCC_CATCH_SIGNALS
@@ -1701,11 +1701,12 @@ Standard_Integer IFSelect_WorkSession::RunTransformer
 {
   Standard_Integer effect = 0;
   if (transf.IsNull() || !IsLoaded()) return effect;
+  
   Handle(Interface_InterfaceModel) newmod;    // Null au depart
   Interface_CheckIterator checks;
   checks.SetName("X-STEP WorkSession : RunTransformer");
   Standard_Boolean res = transf->Perform
-    (thegraph->Graph(),theprotocol,checks,newmod);
+    (thegraph->Graph(),theprotocol,checks,myModel);
 
   if (!checks.IsEmpty(Standard_False)) {
     Handle(Message_Messenger) sout = Message::DefaultMessenger();
@@ -3055,7 +3056,7 @@ Handle(IFSelect_Selection) IFSelect_WorkSession::GiveSelection
   }
 
   Handle(IFSelect_Selection) sel;
-  if (np >= 0)
+  if (np >= 0) 
   {
     nomsel[np] = 0;
   }
index 2cf4d659345ffe658e55c4b549e607dbd2148e1f..1a3b1db4d1ced6b564d07a8d4e071e213a277fde 100644 (file)
@@ -52,14 +52,18 @@ void RWStepVisual_RWPresentationLayerAssignment::ReadStep
        Handle(StepVisual_HArray1OfLayeredItem) aAssignedItems;
        StepVisual_LayeredItem aAssignedItemsItem;
        Standard_Integer nsub3;
-       if (data->ReadSubList (num,3,"assigned_items",ach,nsub3)) {
-         Standard_Integer nb3 = data->NbParams(nsub3);
-         aAssignedItems = new StepVisual_HArray1OfLayeredItem (1, nb3);
-         for (Standard_Integer i3 = 1; i3 <= nb3; i3 ++) {
-           //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
-           if (data->ReadEntity (nsub3,i3,"assigned_items",ach,aAssignedItemsItem))
-             aAssignedItems->SetValue(i3,aAssignedItemsItem);
-         }
+  if (data->ReadSubList(num, 3, "assigned_items", ach, nsub3)) {
+    Standard_Integer nb3 = data->NbParams(nsub3);
+    if (nb3)
+    {
+    
+    aAssignedItems = new StepVisual_HArray1OfLayeredItem(1, nb3);
+    for (Standard_Integer i3 = 1; i3 <= nb3; i3++) {
+      //szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
+      if (data->ReadEntity(nsub3, i3, "assigned_items", ach, aAssignedItemsItem))
+        aAssignedItems->SetValue(i3, aAssignedItemsItem);
+    }
+    }
        }
 
        //--- Initialisation of the read entity ---
index 306609cea814418c82de0595265d028a0b4b2ed6..2f7b682fefbfb0ee891fa1c5bf41bc40be8249e1 100644 (file)
@@ -141,11 +141,22 @@ void  StepData_StepModel::SetIdentLabel
   Standard_Integer num = Number(ent);
   if (!num) 
     return;
+  Standard_Integer nbEnt = NbEntities();
   if(theidnums.IsNull())
   {
-    theidnums = new TColStd_HArray1OfInteger(1, NbEntities());
+    theidnums = new TColStd_HArray1OfInteger(1,nbEnt);
     theidnums->Init(0);
   }
+  else if(nbEnt > theidnums->Length())
+  {
+    Standard_Integer prevLength = theidnums->Length();
+    Handle(TColStd_HArray1OfInteger) idnums1 = new TColStd_HArray1OfInteger(1,nbEnt);
+    idnums1->Init(0);
+    Standard_Integer k =1;
+    for( ; k <= prevLength; k++)
+      idnums1->SetValue(k , theidnums->Value(k));
+    theidnums = idnums1;
+  }
   theidnums->SetValue(num,ident);
 
 }
index 3634d55ef0ed964e85d333bccc125863fabcd643..dc2d3b689f83cad1bfc63854619e038270611df4 100644 (file)
@@ -996,8 +996,8 @@ Standard_Boolean StepData_StepReaderData::ReadReal(const Standard_Integer num,
   Handle(String) errmess;  // Null si pas d erreur
   if (nump > 0 && nump <= NbParams(num)) {
     const Interface_FileParameter& FP = Param(num,nump);
-    if (FP.ParamType() == Interface_ParamReal)  val =
-      Interface_FileReaderData::Fastof(FP.CValue());
+    if (FP.ParamType() == Interface_ParamReal || FP.ParamType() == Interface_ParamInteger) 
+      val = Interface_FileReaderData::Fastof(FP.CValue());
     else errmess = new String("Parameter n0.%d (%s) not a Real");
   }
   else errmess = new String("Parameter n0.%d (%s) absent");
index 623d88c2259edbdd78a882ca93017c1ca67ecc38..98e646414743fc0fdccdcf1e0b62476ae4119888 100644 (file)
@@ -70,8 +70,16 @@ Standard_Integer  StepSelect_WorkLibrary::ReadFile
   long status = 1;
   DeclareAndCast(StepData_Protocol,stepro,protocol);
   if (stepro.IsNull()) return 1;
-  Handle(StepData_StepModel) stepmodel  = new StepData_StepModel;
-  model  = stepmodel;
+   
+   Handle(StepData_StepModel) stepmodel;
+  if(!model.IsNull())
+    stepmodel = Handle(StepData_StepModel)::DownCast(model);
+  if(stepmodel.IsNull())
+  {
+    stepmodel  = new StepData_StepModel;
+    model = stepmodel;
+  }
   StepFile_ReadTrace (0);
   char *pName=(char *)name;
   status = StepFile_Read (pName,stepmodel,stepro);
index c48d6761918f59760368237d863b977555f13135..eed606e60fa1a7ede26f09a209c875ed00771bc7 100644 (file)
@@ -70,5 +70,5 @@ StepVisual_LayeredItem StepVisual_PresentationLayerAssignment::AssignedItemsValu
 
 Standard_Integer StepVisual_PresentationLayerAssignment::NbAssignedItems () const
 {
-       return assignedItems->Length();
+  return (assignedItems.IsNull() ? 0 : assignedItems->Length());
 }