0032666: Data Exchange - Cannot write STEP file from an XCAF document containing... CR0-WEEK-43 IR-2023-10-27
authordorlov <dorlov@opencascade.com>
Mon, 21 Nov 2022 18:13:43 +0000 (18:13 +0000)
committerichesnok <ichesnok@opencascade.com>
Wed, 18 Oct 2023 11:39:00 +0000 (12:39 +0100)
Added support of reading and writing of the triangulated_surface_set.
Prevented creation of tesselated geometry under the schemas different from AP242DIS.
test step_read corrected, switched parameter write.step.schema to AP242DIS in begin and back to AP214CD at the end

26 files changed:
src/RWStepAP214/RWStepAP214_GeneralModule.cxx
src/RWStepAP214/RWStepAP214_ReadWriteModule.cxx
src/RWStepVisual/FILES
src/RWStepVisual/RWStepVisual_RWTriangulatedSurfaceSet.cxx [new file with mode: 0644]
src/RWStepVisual/RWStepVisual_RWTriangulatedSurfaceSet.hxx [new file with mode: 0644]
src/STEPControl/STEPControl_ActorRead.cxx
src/StepAP214/StepAP214_Protocol.cxx
src/StepToTopoDS/StepToTopoDS_Builder.cxx
src/StepToTopoDS/StepToTopoDS_Builder.hxx
src/StepToTopoDS/StepToTopoDS_TranslateFace.cxx
src/StepToTopoDS/StepToTopoDS_TranslateFace.hxx
src/StepVisual/FILES
src/StepVisual/StepVisual_TriangulatedFace.cxx
src/StepVisual/StepVisual_TriangulatedFace.hxx
src/StepVisual/StepVisual_TriangulatedSurfaceSet.cxx [new file with mode: 0644]
src/StepVisual/StepVisual_TriangulatedSurfaceSet.hxx [new file with mode: 0644]
src/TopoDSToStep/TopoDSToStep_Builder.cxx
src/TopoDSToStep/TopoDSToStep_MakeShellBasedSurfaceModel.cxx
src/TopoDSToStep/TopoDSToStep_MakeTessellatedItem.cxx
src/TopoDSToStep/TopoDSToStep_MakeTessellatedItem.hxx
tests/de_mesh/step_read/begin
tests/de_mesh/step_read/end
tests/de_mesh/step_write/D1 [new file with mode: 0644]
tests/de_mesh/step_write/D2 [new file with mode: 0644]
tests/de_mesh/step_write/begin
tests/de_mesh/step_write/end

index 722c5cb7b0dfa194e0058973300b791d148ea40b..052f2c164b06c46c71b79c8af0577cfd09aca68b 100644 (file)
@@ -1372,6 +1372,7 @@ IMPLEMENT_STANDARD_RTTIEXT(RWStepAP214_GeneralModule,StepData_GeneralModule)
 #include <StepVisual_ComplexTriangulatedSurfaceSet.hxx>
 #include <StepVisual_CubicBezierTessellatedEdge.hxx>
 #include <StepVisual_CubicBezierTriangulatedFace.hxx>
+#include <StepVisual_TriangulatedSurfaceSet.hxx>
 
 #include <RWStepVisual_RWTessellatedConnectingEdge.hxx>
 #include <RWStepVisual_RWTessellatedEdge.hxx>
@@ -1388,6 +1389,7 @@ IMPLEMENT_STANDARD_RTTIEXT(RWStepAP214_GeneralModule,StepData_GeneralModule)
 #include <RWStepVisual_RWComplexTriangulatedSurfaceSet.hxx>
 #include <RWStepVisual_RWCubicBezierTessellatedEdge.hxx>
 #include <RWStepVisual_RWCubicBezierTriangulatedFace.hxx>
+#include <RWStepVisual_RWTriangulatedSurfaceSet.hxx>
 
 static Standard_Integer catsh,catdr,catstr,catdsc,cataux;
 
@@ -5867,6 +5869,13 @@ void RWStepAP214_GeneralModule::FillSharedCase(const Standard_Integer CN,
     aTool.Share(anEnt, iter);
   }
   break;
+  case 819:
+  {
+    DeclareAndCast(StepVisual_TriangulatedSurfaceSet, anEnt, ent);
+    RWStepVisual_RWTriangulatedSurfaceSet aTool;
+    aTool.Share(anEnt, iter);
+  }
+  break;
   default : break;
   }
 }
@@ -8173,6 +8182,9 @@ Standard_Boolean RWStepAP214_GeneralModule::NewVoid
    case 818:
      ent = new StepVisual_CubicBezierTriangulatedFace;
      break;
+   case 819:
+     ent = new StepVisual_TriangulatedSurfaceSet;
+     break;
 
   default: 
     return Standard_False;
index a12fe181aee803c5a1e9a158cecc8c342ee0ad84..884be2300d675ef2d3856d029929762ed0a4e9b7 100644 (file)
@@ -455,6 +455,7 @@ IMPLEMENT_STANDARD_RTTIEXT(RWStepAP214_ReadWriteModule,StepData_ReadWriteModule)
 #include <StepVisual_ComplexTriangulatedSurfaceSet.hxx>
 #include <StepVisual_CubicBezierTessellatedEdge.hxx>
 #include <StepVisual_CubicBezierTriangulatedFace.hxx>
+#include <StepVisual_TriangulatedSurfaceSet.hxx>
 
 #include <RWStepVisual_RWTessellatedConnectingEdge.hxx>
 #include <RWStepVisual_RWTessellatedEdge.hxx>
@@ -471,6 +472,7 @@ IMPLEMENT_STANDARD_RTTIEXT(RWStepAP214_ReadWriteModule,StepData_ReadWriteModule)
 #include <RWStepVisual_RWComplexTriangulatedSurfaceSet.hxx>
 #include <RWStepVisual_RWCubicBezierTessellatedEdge.hxx>
 #include <RWStepVisual_RWCubicBezierTriangulatedFace.hxx>
+#include <RWStepVisual_RWTriangulatedSurfaceSet.hxx>
 
 #include <RWStepBasic_RWAddress.hxx>
 #include <RWStepShape_RWAdvancedBrepShapeRepresentation.hxx>
@@ -2349,6 +2351,7 @@ static TCollection_AsciiString Reco_ComplexTriangulatedFace("COMPLEX_TRIANGULATE
 static TCollection_AsciiString Reco_ComplexTriangulatedSurfaceSet("COMPLEX_TRIANGULATED_SURFACE_SET");
 static TCollection_AsciiString Reco_CubicBezierTessellatedEdge("CUBIC_BEZIER_TESSELLATED_EDGE");
 static TCollection_AsciiString Reco_CubicBezierTriangulatedFace("CUBIC_BEZIER_TRIANGULATED_FACE");
+static TCollection_AsciiString Reco_TriangulatedSurfaceSet("TRIANGULATED_SURFACE_SET");
 
 // -- Definition of the libraries --
 
@@ -3105,6 +3108,7 @@ RWStepAP214_ReadWriteModule::RWStepAP214_ReadWriteModule ()
   typenums.Bind(Reco_ComplexTriangulatedSurfaceSet, 816);
   typenums.Bind(Reco_CubicBezierTessellatedEdge, 817);
   typenums.Bind(Reco_CubicBezierTriangulatedFace, 818);
+  typenums.Bind(Reco_TriangulatedSurfaceSet, 819);
 
   
 //    SHORT NAMES
@@ -5092,6 +5096,7 @@ const TCollection_AsciiString& RWStepAP214_ReadWriteModule::StepType
   case 816: return Reco_ComplexTriangulatedSurfaceSet;
   case 817: return Reco_CubicBezierTessellatedEdge;
   case 818: return Reco_CubicBezierTriangulatedFace;
+  case 819: return Reco_TriangulatedSurfaceSet;
   default : return PasReco;
   }
 }
@@ -10694,6 +10699,13 @@ void RWStepAP214_ReadWriteModule::ReadStep(const Standard_Integer CN,
     aTool.ReadStep(data, num, ach, anEnt);
   }
   break;
+  case 819:
+  {
+    DeclareAndCast(StepVisual_TriangulatedSurfaceSet, anEnt, ent);
+    RWStepVisual_RWTriangulatedSurfaceSet aTool;
+    aTool.ReadStep(data, num, ach, anEnt);
+  }
+  break;
   default: 
     ach->AddFail("Type Mismatch when reading - Entity");
   }
@@ -16238,6 +16250,13 @@ void RWStepAP214_ReadWriteModule::WriteStep(const Standard_Integer CN,
     aTool.WriteStep(SW, anEnt);
   }
   break;
+  case 819:
+  {
+    DeclareAndCast(StepVisual_TriangulatedSurfaceSet, anEnt, ent);
+    RWStepVisual_RWTriangulatedSurfaceSet aTool;
+    aTool.WriteStep(SW, anEnt);
+  }
+  break;
   default:
     return;
   }
index c1c2ee0ab6e519b2939156ee6d4cc1d10455d203..e80c78bcdf2bdfaab48e206f0080f1d5eb05377c 100644 (file)
@@ -190,3 +190,5 @@ RWStepVisual_RWTessellatedWire.cxx
 RWStepVisual_RWTessellatedWire.hxx
 RWStepVisual_RWTriangulatedFace.cxx
 RWStepVisual_RWTriangulatedFace.hxx
+RWStepVisual_RWTriangulatedSurfaceSet.cxx
+RWStepVisual_RWTriangulatedSurfaceSet.hxx
diff --git a/src/RWStepVisual/RWStepVisual_RWTriangulatedSurfaceSet.cxx b/src/RWStepVisual/RWStepVisual_RWTriangulatedSurfaceSet.cxx
new file mode 100644 (file)
index 0000000..bf02f6e
--- /dev/null
@@ -0,0 +1,195 @@
+// Copyright (c) Open CASCADE 2023
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <RWStepVisual_RWTriangulatedSurfaceSet.hxx>
+
+#include <StepVisual_TriangulatedSurfaceSet.hxx>
+#include <Interface_EntityIterator.hxx>
+#include <StepData_StepReaderData.hxx>
+#include <StepData_StepWriter.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <StepVisual_CoordinatesList.hxx>
+#include <Standard_Integer.hxx>
+#include <TColStd_HArray2OfReal.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+#include <Standard_Real.hxx>
+#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_HArray2OfInteger.hxx>
+
+//=======================================================================
+//function : RWStepVisual_RWTriangulatedSurfaceSet
+//purpose  :
+//=======================================================================
+RWStepVisual_RWTriangulatedSurfaceSet::RWStepVisual_RWTriangulatedSurfaceSet()
+{
+}
+
+//=======================================================================
+//function : ReadStep
+//purpose  :
+//=======================================================================
+void RWStepVisual_RWTriangulatedSurfaceSet::ReadStep(const Handle(StepData_StepReaderData)& theData,
+                                                     const Standard_Integer theNum,
+                                                     Handle(Interface_Check)& theCheck,
+                                                     const Handle(StepVisual_TriangulatedSurfaceSet)& theEnt) const
+{
+  // Check number of parameters
+  if (!theData->CheckNbParams(theNum, 6, theCheck, "triangulated_surface_set"))
+  {
+    return;
+  }
+
+  // Inherited fields of RepresentationItem
+  Handle(TCollection_HAsciiString) aRepresentationItem_Name;
+  theData->ReadString(theNum, 1, "representation_item.name", theCheck, aRepresentationItem_Name);
+
+  // Inherited fields of TessellatedSurfaceSet
+  Handle(StepVisual_CoordinatesList) aTessellatedSurfaceSet_Coordinates;
+  theData->ReadEntity(theNum, 2, "tessellated_surface_set.coordinates", theCheck,
+    STANDARD_TYPE(StepVisual_CoordinatesList), aTessellatedSurfaceSet_Coordinates);
+
+  Standard_Integer aTessellatedSurfaceSet_Pnmax;
+  theData->ReadInteger(theNum, 3, "tessellated_surface_set.pnmax", theCheck, aTessellatedSurfaceSet_Pnmax);
+
+  Handle(TColStd_HArray2OfReal) aTessellatedSurfaceSet_Normals;
+  Standard_Integer aNormSub4 = 0;
+  if (theData->ReadSubList(theNum, 4, "tessellated_surface_set.normals", theCheck, aNormSub4))
+  {
+    const Standard_Integer aNormNb = theData->NbParams(aNormSub4);
+    const Standard_Integer anAxesNb = theData->NbParams(theData->ParamNumber(aNormSub4, 1));
+    aTessellatedSurfaceSet_Normals = new TColStd_HArray2OfReal(1, aNormNb, 1, anAxesNb);
+    for (Standard_Integer aNormIndex = 1; aNormIndex <= aNormNb; aNormIndex++)
+    {
+      Standard_Integer anAxesSub4 = 0;
+      if (theData->ReadSubList(aNormSub4, aNormIndex, 
+                               "sub-part(tessellated_surface_set.normals)", 
+                               theCheck, anAxesSub4))
+      {
+        const Standard_Integer anAxisNum4 = anAxesSub4;
+        for (Standard_Integer anAxisIndex = 1; anAxisIndex <= anAxesNb; anAxisIndex++)
+        {
+          Standard_Real aValue;
+          theData->ReadReal(anAxisNum4, anAxisIndex, "real", theCheck, aValue);
+          aTessellatedSurfaceSet_Normals->SetValue(aNormIndex, anAxisIndex, aValue);
+        }
+      }
+    }
+  }
+
+  // Own fields of TriangulatedSurfaceSet
+  Handle(TColStd_HArray1OfInteger) aPnindex;
+  Standard_Integer aPnSub5 = 0;
+  if (theData->ReadSubList(theNum, 5, "pnindex", theCheck, aPnSub5))
+  {
+    const Standard_Integer aPnNb = theData->NbParams(aPnSub5);
+    aPnindex = new TColStd_HArray1OfInteger(1, aPnNb);
+    const Standard_Integer aPnNum2 = aPnSub5;
+    for (Standard_Integer aPnIndex = 1; aPnIndex <= aPnNb; aPnIndex++)
+    {
+      Standard_Integer aValue;
+      theData->ReadInteger(aPnNum2, aPnIndex, "integer", theCheck, aValue);
+      aPnindex->SetValue(aPnIndex, aValue);
+    }
+  }
+
+  Handle(TColStd_HArray2OfInteger) aTriangles;
+  Standard_Integer aTrSub6 = 0;
+  if (theData->ReadSubList(theNum, 6, "triangles", theCheck, aTrSub6))
+  {
+    const Standard_Integer aTriaNb = theData->NbParams(aTrSub6);
+    const Standard_Integer anAxesNb = theData->NbParams(theData->ParamNumber(aTrSub6, 1));
+    aTriangles = new TColStd_HArray2OfInteger(1, aTriaNb, 1, anAxesNb);
+    for (Standard_Integer aTriaIndex = 1; aTriaIndex <= aTriaNb; aTriaIndex++)
+    {
+      Standard_Integer anAxesSubj6 = 0;
+      if (theData->ReadSubList(aTrSub6, aTriaIndex, "sub-part(triangles)", theCheck, anAxesSubj6))
+      {
+        const Standard_Integer anAxisNum4 = anAxesSubj6;
+        for (Standard_Integer anAxisIndex = 1; anAxisIndex <= anAxesNb; anAxisIndex++)
+        {
+          Standard_Integer aValue;
+          theData->ReadInteger(anAxisNum4, anAxisIndex, "integer", theCheck, aValue);
+          aTriangles->SetValue(aTriaIndex, anAxisIndex, aValue);
+        }
+      }
+    }
+  }
+
+  // Initialize entity
+  theEnt->Init(aRepresentationItem_Name, aTessellatedSurfaceSet_Coordinates, 
+               aTessellatedSurfaceSet_Pnmax, aTessellatedSurfaceSet_Normals, aPnindex, aTriangles);
+}
+
+//=======================================================================
+//function : WriteStep
+//purpose  :
+//=======================================================================
+void RWStepVisual_RWTriangulatedSurfaceSet::WriteStep(StepData_StepWriter& theSW,
+                                                      const Handle(StepVisual_TriangulatedSurfaceSet)& theEnt) const
+{
+  // Own fields of RepresentationItem
+  theSW.Send(theEnt->Name());
+
+  // Own fields of TessellatedSurfaceSet
+  theSW.Send(theEnt->Coordinates());
+  theSW.Send(theEnt->Pnmax());
+
+  theSW.OpenSub();
+  for (Standard_Integer aNormIndex = 1; aNormIndex <= theEnt->Normals()->NbRows(); aNormIndex++)
+  {
+    theSW.NewLine(Standard_False);
+    theSW.OpenSub();
+    for (Standard_Integer anAxisIndex = 1; anAxisIndex <= theEnt->Normals()->NbColumns(); anAxisIndex++)
+    {
+      const Standard_Real aValue = theEnt->Normals()->Value(aNormIndex, anAxisIndex);
+      theSW.Send(aValue);
+    }
+    theSW.CloseSub();
+  }
+  theSW.CloseSub();
+
+  // Own fields of TriangulatedSurfaceSet
+  theSW.OpenSub();
+  TColStd_HArray1OfInteger::Iterator aPnIndexIt(theEnt->Pnindex()->Array1());
+  for (; aPnIndexIt.More(); aPnIndexIt.Next())
+  {
+    const Standard_Integer aValue = aPnIndexIt.Value();
+    theSW.Send(aValue);
+  }
+  theSW.CloseSub();
+
+  theSW.OpenSub();
+  for (Standard_Integer aTriaIndex = 1; aTriaIndex <= theEnt->Triangles()->NbRows(); aTriaIndex++)
+  {
+    theSW.NewLine(Standard_False);
+    theSW.OpenSub();
+    for (Standard_Integer anAxisIndex = 1; anAxisIndex <= theEnt->Triangles()->NbColumns(); anAxisIndex++)
+    {
+      const Standard_Integer aValue = theEnt->Triangles()->Value(aTriaIndex, anAxisIndex);
+      theSW.Send(aValue);
+    }
+    theSW.CloseSub();
+  }
+  theSW.CloseSub();
+}
+
+//=======================================================================
+//function : Share
+//purpose  :
+//=======================================================================
+void RWStepVisual_RWTriangulatedSurfaceSet::Share(const Handle(StepVisual_TriangulatedSurfaceSet)&theEnt,
+                                                  Interface_EntityIterator& theIter) const
+{
+  // Inherited fields of TessellatedSurfaceSet
+  theIter.AddItem(theEnt->StepVisual_TessellatedSurfaceSet::Coordinates());
+}
diff --git a/src/RWStepVisual/RWStepVisual_RWTriangulatedSurfaceSet.hxx b/src/RWStepVisual/RWStepVisual_RWTriangulatedSurfaceSet.hxx
new file mode 100644 (file)
index 0000000..38fafbc
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (c) Open CASCADE 2023
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _RWStepVisual_RWTriangulatedSurfaceSet_HeaderFile_
+#define _RWStepVisual_RWTriangulatedSurfaceSet_HeaderFile_
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Handle.hxx>
+
+class StepData_StepReaderData;
+class Interface_Check;
+class StepData_StepWriter;
+class Interface_EntityIterator;
+class StepVisual_TriangulatedSurfaceSet;
+
+//! Read & Write tool for TriangulatedSurfaceSet
+class RWStepVisual_RWTriangulatedSurfaceSet
+{
+public:
+  DEFINE_STANDARD_ALLOC
+
+  //! default constructor
+  Standard_EXPORT RWStepVisual_RWTriangulatedSurfaceSet();
+
+  Standard_EXPORT void ReadStep(const Handle(StepData_StepReaderData)& theData,
+                                const Standard_Integer theNum,
+                                Handle(Interface_Check)& theCheck,
+                                const Handle(StepVisual_TriangulatedSurfaceSet)& theEnt) const;
+
+  Standard_EXPORT void WriteStep(StepData_StepWriter& theSW,
+                                 const Handle(StepVisual_TriangulatedSurfaceSet)& theEnt) const;
+
+  Standard_EXPORT void Share(const Handle(StepVisual_TriangulatedSurfaceSet)& theEnt,
+                             Interface_EntityIterator& theIter) const;
+};
+
+#endif // _RWStepVisual_RWTriangulatedSurfaceSet_HeaderFile_
index fcdd8c7ab44786905bb3993d8f32c0a3f8610c6c..952054f702b1d861fed39b4d63e1b8fe8344d296 100644 (file)
@@ -89,6 +89,7 @@
 #include <StepShape_ShapeRepresentation.hxx>
 #include <StepShape_ShellBasedSurfaceModel.hxx>
 #include <StepVisual_TriangulatedFace.hxx>
+#include <StepVisual_TriangulatedSurfaceSet.hxx>
 #include <StepVisual_TessellatedShell.hxx>
 #include <StepVisual_TessellatedShapeRepresentation.hxx>
 #include <StepVisual_TessellatedSolid.hxx>
@@ -256,6 +257,7 @@ Standard_Boolean  STEPControl_ActorRead::Recognize
   if (start->IsKind(STANDARD_TYPE(StepShape_EdgeBasedWireframeModel))) return Standard_True;
   if (start->IsKind(STANDARD_TYPE(StepShape_FaceBasedSurfaceModel))) return Standard_True;
   if (aCanReadTessGeom && start->IsKind(STANDARD_TYPE(StepVisual_TessellatedFace))) return Standard_True;
+  if (aCanReadTessGeom && start->IsKind(STANDARD_TYPE(StepVisual_TessellatedSurfaceSet))) return Standard_True;
   if (aCanReadTessGeom && start->IsKind(STANDARD_TYPE(StepVisual_TessellatedShell))) return Standard_True;
   if (aCanReadTessGeom && start->IsKind(STANDARD_TYPE(StepVisual_TessellatedSolid))) return Standard_True;
   if (aCanReadTessGeom && start->IsKind(STANDARD_TYPE(StepVisual_TessellatedShapeRepresentation))) return Standard_True;
@@ -1486,6 +1488,11 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity
                           aReadTessellatedWhenNoBRepOnly, aHasGeom, aLocalFactors);
       found = Standard_True;
     }
+    else if (start->IsKind(STANDARD_TYPE(StepVisual_TessellatedSurfaceSet)))
+    {
+      myShapeBuilder.Init(GetCasted(StepVisual_TessellatedSurfaceSet, start), TP, aLocalFactors, aHasGeom);
+      found = Standard_True;
+    }
   }
   catch(Standard_Failure const&) {
     TP->AddFail(start,"Exception is raised. Entity was not translated.");
index 827ef454ebc5bf1510d7cd9b0f09f4e52359517b..16643aa1784d219b13b18b10dc5fda70eafd417f 100644 (file)
@@ -748,9 +748,10 @@ static Standard_CString schemaAP242DIS = "AP242_MANAGED_MODEL_BASED_3D_ENGINEERI
 #include <StepVisual_ComplexTriangulatedSurfaceSet.hxx>
 #include <StepVisual_CubicBezierTessellatedEdge.hxx>
 #include <StepVisual_CubicBezierTriangulatedFace.hxx>
+#include <StepVisual_TriangulatedSurfaceSet.hxx>
 
 static int THE_StepAP214_Protocol_init = 0;
-static Interface_DataMapOfTransientInteger types(803);
+static Interface_DataMapOfTransientInteger types(819);
 
 //=======================================================================
 //function : StepAP214_Protocol
@@ -1558,6 +1559,7 @@ StepAP214_Protocol::StepAP214_Protocol ()
   types.Bind(STANDARD_TYPE(StepVisual_ComplexTriangulatedSurfaceSet), 816);
   types.Bind(STANDARD_TYPE(StepVisual_CubicBezierTessellatedEdge), 817);
   types.Bind(STANDARD_TYPE(StepVisual_CubicBezierTriangulatedFace), 818);
+  types.Bind(STANDARD_TYPE(StepVisual_TriangulatedSurfaceSet), 819);
 }
 
 
index 82bbe14a983ee9df82dc9e3af95ecbcee3c2e6fd..9d1db3d618016aa8914bdd255fe724ddddd7f50d 100644 (file)
@@ -66,6 +66,7 @@
 #include <StepVisual_TessellatedFace.hxx>
 #include <StepVisual_TessellatedShell.hxx>
 #include <StepVisual_TessellatedSolid.hxx>
+#include <StepVisual_TessellatedSurfaceSet.hxx>
 #include <StepToGeom.hxx>
 #include <StepToTopoDS_Builder.hxx>
 #include <StepToTopoDS_NMTool.hxx>
@@ -100,10 +101,9 @@ static void ResetPreci (const TopoDS_Shape& S, Standard_Real maxtol)
 }
 
 // ============================================================================
-// Method  : StepToTopoDS_Builder::StepToTopoDS_Builder
+// Method  : StepToTopoDS_Builder
 // Purpose : Empty constructor
 // ============================================================================
-
 StepToTopoDS_Builder::StepToTopoDS_Builder()
 : myError(StepToTopoDS_BuilderOther)
 {
@@ -114,293 +114,257 @@ StepToTopoDS_Builder::StepToTopoDS_Builder()
 // Method  : Init
 // Purpose : Init with a ManifoldSolidBrep
 // ============================================================================
-
-void StepToTopoDS_Builder::Init
-(const Handle(StepShape_ManifoldSolidBrep)& aManifoldSolid,
- const Handle(Transfer_TransientProcess)& TP,
- const StepData_Factors& theLocalFactors,
- const Message_ProgressRange& theProgress)
+void StepToTopoDS_Builder::Init(const Handle(StepShape_ManifoldSolidBrep)& theManifoldSolid,
+                                const Handle(Transfer_TransientProcess)& theTP,
+                                const StepData_Factors& theLocalFactors,
+                                const Message_ProgressRange& theProgress)
 {
-  Message_Messenger::StreamBuffer sout = TP->Messenger()->SendInfo();
+  Message_Messenger::StreamBuffer sout = theTP->Messenger()->SendInfo();
   // Initialisation of the Tool
 
-  StepToTopoDS_Tool         myTool;
+  StepToTopoDS_Tool         aTool;
   StepToTopoDS_DataMapOfTRI aMap;
 
-  myTool.Init(aMap, TP);
+  aTool.Init(aMap, theTP);
 
   // Start Mapping
-
-  Handle(StepShape_ConnectedFaceSet) aShell;
-  aShell = aManifoldSolid->Outer();
+  const Handle(StepShape_ConnectedFaceSet) aShell = theManifoldSolid->Outer();
 
   StepToTopoDS_TranslateShell myTranShell;
   myTranShell.SetPrecision(Precision());
   myTranShell.SetMaxTol(MaxTol());
-  // Non-manifold topology is not referenced by ManifoldSolidBrep (ssv; 14.11.2010)
-  StepToTopoDS_NMTool dummyNMTool;
-  myTranShell.Init(aShell, myTool, dummyNMTool, theLocalFactors, theProgress);
-
-  if (myTranShell.IsDone()) {
-    TopoDS_Shape Sh = myTranShell.Value();
-    Sh.Closed(Standard_True);
-    //BRepLib::SameParameter(Sh);
-    TopoDS_Solid S;
-    BRep_Builder B;
-    B.MakeSolid(S);
-    B.Add(S,Sh);
-    myResult = S;
-    myError  = StepToTopoDS_BuilderDone;
-    done     = Standard_True;
 
-    // Get Statistics :
-
-    if ( TP->TraceLevel() > 2 )
-    {
-      sout << "Geometric Statistics : " << std::endl;
-      sout << "   Surface Continuity : - C0 : " << myTool.C0Surf() << std::endl;
-      sout << "                        - C1 : " << myTool.C1Surf() << std::endl;
-      sout << "                        - C2 : " << myTool.C2Surf() << std::endl;
-      sout << "   Curve Continuity :   - C0 : " << myTool.C0Cur3() << std::endl;
-      sout << "                        - C1 : " << myTool.C1Cur3() << std::endl;
-      sout << "                        - C2 : " << myTool.C2Cur3() << std::endl;
-      sout << "   PCurve Continuity :  - C0 : " << myTool.C0Cur2() << std::endl;
-      sout << "                        - C1 : " << myTool.C1Cur2() << std::endl;
-      sout << "                        - C2 : " << myTool.C2Cur2() << std::endl;
-    }
-
-//:S4136    ShapeFix::SameParameter (S,Standard_False);
-    ResetPreci (S, MaxTol());
+  StepToTopoDS_NMTool dummyNMTool;
+  myTranShell.Init(aShell, aTool, dummyNMTool, theLocalFactors, theProgress);
+  if (!myTranShell.IsDone())
+  {
+    theTP->AddWarning(aShell, " OuterShell from ManifoldSolidBrep not mapped to TopoDS");
+    myError = StepToTopoDS_BuilderOther;
+    done = Standard_False;
+    return;
   }
-  else {
-    TP->AddWarning(aShell," OuterShell from ManifoldSolidBrep not mapped to TopoDS");
-    myError  = StepToTopoDS_BuilderOther;
-    done     = Standard_False;
+  TopoDS_Shape aShape = myTranShell.Value();
+  aShape.Closed(Standard_True);
+  TopoDS_Solid aSolid;
+  BRep_Builder aBuilder;
+  aBuilder.MakeSolid(aSolid);
+  aBuilder.Add(aSolid, aShape);
+  myResult = aSolid;
+  myError  = StepToTopoDS_BuilderDone;
+  done     = Standard_True;
+
+  // Get Statistics :
+  if (theTP->TraceLevel() > 2)
+  {
+    sout << "Geometric Statistics : " << std::endl;
+    sout << "   Surface Continuity : - C0 : " << aTool.C0Surf() << std::endl;
+    sout << "                        - C1 : " << aTool.C1Surf() << std::endl;
+    sout << "                        - C2 : " << aTool.C2Surf() << std::endl;
+    sout << "   Curve Continuity :   - C0 : " << aTool.C0Cur3() << std::endl;
+    sout << "                        - C1 : " << aTool.C1Cur3() << std::endl;
+    sout << "                        - C2 : " << aTool.C2Cur3() << std::endl;
+    sout << "   PCurve Continuity :  - C0 : " << aTool.C0Cur2() << std::endl;
+    sout << "                        - C1 : " << aTool.C1Cur2() << std::endl;
+    sout << "                        - C2 : " << aTool.C2Cur2() << std::endl;
   }
+
+  ResetPreci (aSolid, MaxTol());
 }
 
 // ============================================================================
 // Method  : Init
 // Purpose : Init with a BrepWithVoids
 // ============================================================================
-
-void StepToTopoDS_Builder::Init
-(const Handle(StepShape_BrepWithVoids)& aBRepWithVoids,
- const Handle(Transfer_TransientProcess)& TP,
- const StepData_Factors& theLocalFactors,
- const Message_ProgressRange& theProgress)
+void StepToTopoDS_Builder::Init(const Handle(StepShape_BrepWithVoids)& theBRepWithVoids,
+                                const Handle(Transfer_TransientProcess)& theTP,
+                                const StepData_Factors& theLocalFactors,
+                                const Message_ProgressRange& theProgress)
 {
-  Message_Messenger::StreamBuffer sout = TP->Messenger()->SendInfo();
+  Message_Messenger::StreamBuffer sout = theTP->Messenger()->SendInfo();
  // Initialisation of the Tool
-  StepToTopoDS_Tool         myTool;
+  StepToTopoDS_Tool         aTool;
   StepToTopoDS_DataMapOfTRI aMap;
 
-  myTool.Init(aMap, TP);
+  aTool.Init(aMap, theTP);
 
   // Start Mapping
-
-  Standard_Integer Nb = aBRepWithVoids->NbVoids();
-  Handle(StepShape_ClosedShell) aCShell;
-  TopoDS_Solid S;
-  TopoDS_Shape Sh;
-  BRep_Builder B;
-  B.MakeSolid(S);
+  TopoDS_Solid aSolid;
+  BRep_Builder aBuilder;
+  aBuilder.MakeSolid(aSolid);
   
-  Message_ProgressScope PS (theProgress, "Shell", Nb+1);
+  Message_ProgressScope aPS (theProgress, "Shell", theBRepWithVoids->NbVoids() + 1);
 
-  StepToTopoDS_TranslateShell myTranShell;
+  StepToTopoDS_TranslateShell aTranShell;
 
-  myTranShell.SetPrecision(Precision());//gka
-  myTranShell.SetMaxTol(MaxTol());
+  aTranShell.SetPrecision(Precision());//gka
+  aTranShell.SetMaxTol(MaxTol());
   // OuterBound
 
-  aCShell = Handle(StepShape_ClosedShell)::DownCast(aBRepWithVoids->Outer());
+  Handle(StepShape_ClosedShell) aCShell = Handle(StepShape_ClosedShell)::DownCast(theBRepWithVoids->Outer());
   // Non-manifold topology is not referenced by BrepWithVoids (ssv; 14.11.2010)
-  StepToTopoDS_NMTool dummyNMTool;
-  myTranShell.Init(aCShell, myTool, dummyNMTool, theLocalFactors, PS.Next());
-
-  if (myTranShell.IsDone()) {
-    Sh = myTranShell.Value();
-    Sh.Closed(Standard_True);
-    //BRepLib::SameParameter(Sh);
-    B.MakeSolid(S);
-    B.Add(S,Sh);
-    myResult = S;
-    myError  = StepToTopoDS_BuilderDone;
-    done     = Standard_True;
-  }
-  else {
-    TP->AddWarning(aCShell," OuterShell from BrepWithVoids not mapped to TopoDS");
-    myError  = StepToTopoDS_BuilderOther;
-    done     = Standard_False;
+  StepToTopoDS_NMTool aDummyNMTool;
+  aTranShell.Init(aCShell, aTool, aDummyNMTool, theLocalFactors, aPS.Next());
+  if (!aTranShell.IsDone())
+  {
+    theTP->AddWarning( aCShell, " OuterShell from BrepWithVoids not mapped to TopoDS" );
+    myError = StepToTopoDS_BuilderOther;
+    done = Standard_False;
     return;
   }
+  TopoDS_Shape aShape = aTranShell.Value();
+  aShape.Closed(Standard_True);
+  aBuilder.MakeSolid(aSolid);
+  aBuilder.Add(aSolid, aShape);
+  myResult = aSolid;
+  myError  = StepToTopoDS_BuilderDone;
+  done     = Standard_True;
 
   // Voids
-
-  for (Standard_Integer i=1; i<=Nb && PS.More(); i++) {
-
-    aCShell = aBRepWithVoids->VoidsValue(i);
-    myTranShell.Init(aCShell, myTool, dummyNMTool, theLocalFactors, PS.Next());
-    if (myTranShell.IsDone()) {
-      Sh = myTranShell.Value();
-      Sh.Closed(Standard_True);
+  for (StepShape_HArray1OfOrientedClosedShell::Iterator anIt(theBRepWithVoids->Voids()->Array1());
+       anIt.More() && aPS.More(); anIt.Next())
+  {
+    Handle(StepShape_OrientedClosedShell) anOCShell = anIt.Value();
+    aTranShell.Init(anOCShell, aTool, aDummyNMTool, theLocalFactors, aPS.Next());
+    if (aTranShell.IsDone())
+    {
+      aShape = aTranShell.Value();
+      aShape.Closed(Standard_True);
 
       //:e0 abv 25 Mar 98: void should be an OrientedShell 
-      Handle(StepShape_OrientedClosedShell) aOCShell = aBRepWithVoids->VoidsValue(i);
-      if ( ! aOCShell.IsNull() && ! aOCShell->Orientation() ) Sh.Reverse();
-      
-      //BRepLib::SameParameter(Sh);
-      B.Add(S,Sh);
+      if (!anOCShell.IsNull() && ! anOCShell->Orientation())
+        aShape.Reverse();
+
+      aBuilder.Add(aSolid, aShape);
     }
-    else {
-      TP->AddWarning
-       (aCShell," A Void from BrepWithVoids not mapped to TopoDS");
+    else
+    {
+      theTP->AddWarning (anOCShell, " A Void from BrepWithVoids not mapped to TopoDS");
     }
   }
-  myResult = S;
-
+  myResult = aSolid;
 
   // Get Statistics :
-  
-  if ( TP->TraceLevel() > 2 )
+  if (theTP->TraceLevel() > 2)
   {
     sout << "Geometric Statistics : " << std::endl;
-    sout << "   Surface Continuity : - C0 : " << myTool.C0Surf() << std::endl;
-    sout << "                        - C1 : " << myTool.C1Surf() << std::endl;
-    sout << "                        - C2 : " << myTool.C2Surf() << std::endl;
-    sout << "   Curve Continuity :   - C0 : " << myTool.C0Cur3() << std::endl;
-    sout << "                        - C1 : " << myTool.C1Cur3() << std::endl;
-    sout << "                        - C2 : " << myTool.C2Cur3() << std::endl;
-    sout << "   PCurve Continuity :  - C0 : " << myTool.C0Cur2() << std::endl;
-    sout << "                        - C1 : " << myTool.C1Cur2() << std::endl;
-    sout << "                        - C2 : " << myTool.C2Cur2() << std::endl;
+    sout << "   Surface Continuity : - C0 : " << aTool.C0Surf() << std::endl;
+    sout << "                        - C1 : " << aTool.C1Surf() << std::endl;
+    sout << "                        - C2 : " << aTool.C2Surf() << std::endl;
+    sout << "   Curve Continuity :   - C0 : " << aTool.C0Cur3() << std::endl;
+    sout << "                        - C1 : " << aTool.C1Cur3() << std::endl;
+    sout << "                        - C2 : " << aTool.C2Cur3() << std::endl;
+    sout << "   PCurve Continuity :  - C0 : " << aTool.C0Cur2() << std::endl;
+    sout << "                        - C1 : " << aTool.C1Cur2() << std::endl;
+    sout << "                        - C2 : " << aTool.C2Cur2() << std::endl;
   }
 
-//:S4136  ShapeFix::SameParameter (S,Standard_False);
-  ResetPreci (S, MaxTol());
+  ResetPreci (aSolid, MaxTol());
 }
 
 // ============================================================================
 // Method  : Init
 // Purpose : Init with a FacetedBrep
 // ============================================================================
-
-void StepToTopoDS_Builder::Init(const Handle(StepShape_FacetedBrep)& aFB,
-                                const Handle(Transfer_TransientProcess)& TP,
+void StepToTopoDS_Builder::Init(const Handle(StepShape_FacetedBrep)& theFB,
+                                const Handle(Transfer_TransientProcess)& theTP,
                                 const StepData_Factors& theLocalFactors,
                                 const Message_ProgressRange& theProgress)
 {
   // Initialisation of the Tool
-
-  StepToTopoDS_Tool         myTool;
+  StepToTopoDS_Tool         aTool;
   StepToTopoDS_DataMapOfTRI aMap;
 
-  myTool.Init(aMap, TP);
+  aTool.Init(aMap, theTP);
 
   // Start Mapping
+  const Handle(StepShape_ClosedShell) aCShell = Handle(StepShape_ClosedShell)::DownCast(theFB->Outer());
 
-  Handle(StepShape_ClosedShell) aCShell;
-  aCShell = Handle(StepShape_ClosedShell)::DownCast(aFB->Outer());
-  TopoDS_Shape Sh;
-
-  StepToTopoDS_TranslateShell myTranShell; 
-  myTranShell.SetPrecision(Precision()); //gka
-  myTranShell.SetMaxTol(MaxTol());  
+  StepToTopoDS_TranslateShell aTranShell; 
+  aTranShell.SetPrecision(Precision()); //gka
+  aTranShell.SetMaxTol(MaxTol());  
   // Non-manifold topology is not referenced by FacetedBrep (ss; 14.11.2010)
-  StepToTopoDS_NMTool dummyNMTool;
-  myTranShell.Init(aCShell, myTool, dummyNMTool, theLocalFactors, theProgress);
-
-  if (myTranShell.IsDone()) {
-    Sh = myTranShell.Value();
-    Sh.Closed(Standard_True);
-    //BRepLib::SameParameter(Sh);
-    myTool.ClearEdgeMap();
-    myTool.ClearVertexMap();
-    TopoDS_Solid S;
-    BRep_Builder B;
-    B.MakeSolid(S);
-    B.Add(S,Sh);
-    myResult = S;
-    myError  = StepToTopoDS_BuilderDone;
-    done     = Standard_True;
-  }
-  else {
-    TP->AddWarning
-      (aCShell," OuterShell from FacetedBrep not mapped to TopoDS");
-    myError  = StepToTopoDS_BuilderOther;
-    done     = Standard_True;
+  StepToTopoDS_NMTool aDummyNMTool;
+  aTranShell.Init(aCShell, aTool, aDummyNMTool, theLocalFactors, theProgress);
+  if (!aTranShell.IsDone()) 
+  {
+    theTP->AddWarning(aCShell, " OuterShell from FacetedBrep not mapped to TopoDS");
+    myError = StepToTopoDS_BuilderOther;
+    done = Standard_False;
+    return;
   }
+  TopoDS_Shape aShape = aTranShell.Value();
+  aShape.Closed(Standard_True);
+  aTool.ClearEdgeMap();
+  aTool.ClearVertexMap();
+  TopoDS_Solid aSolid;
+  BRep_Builder aBuilder;
+  aBuilder.MakeSolid(aSolid);
+  aBuilder.Add(aSolid, aShape);
+  myResult = aSolid;
+  myError  = StepToTopoDS_BuilderDone;
+  done     = Standard_True;
 }
 
 // ============================================================================
 // Method  : Init
 // Purpose : Init with a FacetedBrepAndBrepWithVoids
 // ============================================================================
-
-void StepToTopoDS_Builder::Init
-(const Handle(StepShape_FacetedBrepAndBrepWithVoids)& aFBABWV,
- const Handle(Transfer_TransientProcess)& TP,
- const StepData_Factors& theLocalFactors,
- const Message_ProgressRange& theProgress)
-{
+void StepToTopoDS_Builder::Init(const Handle(StepShape_FacetedBrepAndBrepWithVoids)& theFBABWV,
+                                const Handle(Transfer_TransientProcess)& theTP,
+                                const StepData_Factors& theLocalFactors,
+                                const Message_ProgressRange& theProgress){
   // Initialisation of the Tool
-
-  StepToTopoDS_Tool         myTool;
+  StepToTopoDS_Tool         aTool;
   StepToTopoDS_DataMapOfTRI aMap;
 
-  myTool.Init(aMap, TP);
+  aTool.Init(aMap, theTP);
 
   // Start Mapping
-
-  Handle(StepShape_ClosedShell) aCShell;
-  aCShell = Handle(StepShape_ClosedShell)::DownCast(aFBABWV->Outer());
-  TopoDS_Shape Sh;
+  Handle(StepShape_ClosedShell) aCShell = Handle(StepShape_ClosedShell)::DownCast(theFBABWV->Outer());
 
   Message_ProgressScope aPSRoot(theProgress, NULL, 2);
 
-  StepToTopoDS_TranslateShell myTranShell;
-  myTranShell.SetPrecision(Precision()); //gka
-  myTranShell.SetMaxTol(MaxTol());
+  StepToTopoDS_TranslateShell aTranShell;
+  aTranShell.SetPrecision(Precision()); //gka
+  aTranShell.SetMaxTol(MaxTol());
   // Non-manifold topology is not referenced by FacetedBrepAndBrepWithVoids (ss; 14.11.2010)
-  StepToTopoDS_NMTool dummyNMTool;
-  myTranShell.Init(aCShell, myTool, dummyNMTool, theLocalFactors, aPSRoot.Next());
-
-  if (myTranShell.IsDone()) {
-    Sh = myTranShell.Value();
-    Sh.Closed(Standard_True);
-    //BRepLib::SameParameter(Sh);
-    TopoDS_Solid S;
-    BRep_Builder B;
-    B.MakeSolid(S);
-    B.Add(S,Sh);
-    Standard_Integer Nb, i;
-    Nb = aFBABWV->NbVoids();
-    Message_ProgressScope aPS (aPSRoot.Next(), NULL, Nb);
-    for ( i=1; i<=Nb && aPS.More(); i++) {
-      aCShell = aFBABWV->VoidsValue(i);
-      myTranShell.Init(aCShell, myTool, dummyNMTool, theLocalFactors, aPS.Next());
-      if (myTranShell.IsDone()) {
-        Sh = myTranShell.Value();
-        Sh.Closed(Standard_True);
-        //BRepLib::SameParameter(Sh);
-        B.Add(S, Sh);
-      }
-      else {
-       TP->AddWarning
-         (aCShell," A Void from FacetedBrepAndBrepWithVoids not mapped to TopoDS");
-      }
-    }
-    myResult = S;
-    myError  = StepToTopoDS_BuilderDone;
-    done     = Standard_True;
-  }
-  else {
-    TP->AddWarning
-      (aCShell," OuterShell from FacetedBrepAndBrepWithVoids not mapped to TopoDS");
-    done    = Standard_False;
+  StepToTopoDS_NMTool aDummyNMTool;
+  aTranShell.Init(aCShell, aTool, aDummyNMTool, theLocalFactors, aPSRoot.Next());
+  if (!aTranShell.IsDone()) 
+  {
+    theTP->AddWarning
+      (aCShell, " OuterShell from FacetedBrepAndBrepWithVoids not mapped to TopoDS");
+    done = Standard_False;
     myError = StepToTopoDS_BuilderOther;
+    return;
+  }
+  TopoDS_Shape aShape = aTranShell.Value();
+  aShape.Closed(Standard_True);
+  TopoDS_Solid aSolid;
+  BRep_Builder aBuilder;
+  aBuilder.MakeSolid(aSolid);
+  aBuilder.Add(aSolid, aShape);
+  Message_ProgressScope aPS (aPSRoot.Next(), NULL, theFBABWV->NbVoids());
+  for (StepShape_HArray1OfOrientedClosedShell::Iterator anIt(theFBABWV->Voids()->Array1());
+       anIt.More() && aPS.More(); anIt.Next())
+  {
+    Handle(StepShape_OrientedClosedShell) anOCShell = anIt.Value();
+    aTranShell.Init(anOCShell, aTool, aDummyNMTool, theLocalFactors, aPS.Next());
+    if (aTranShell.IsDone()) 
+    {
+      aShape = aTranShell.Value();
+      aShape.Closed(Standard_True);
+      aBuilder.Add(aSolid, aShape);
+    }
+    else 
+    {
+      theTP->AddWarning
+        (anOCShell, " A Void from FacetedBrepAndBrepWithVoids not mapped to TopoDS");
+    }
   }
+  myResult = aSolid;
+  myError  = StepToTopoDS_BuilderDone;
+  done     = Standard_True;
 }
 
 // ============================================================================
@@ -815,10 +779,9 @@ void StepToTopoDS_Builder::Init
 // ***end DTH Apr/6 
 
 // ============================================================================
-// Method  : StepToTopoDS_Builder::Init
+// Method  : Init
 // Purpose : Builds a TopoDS_Solid from StepVisual_TessellatedSolid
 // ============================================================================
-
 void StepToTopoDS_Builder::Init(const Handle(StepVisual_TessellatedSolid)& theTSo,
                                 const Handle(Transfer_TransientProcess)& theTP,
                                 const Standard_Boolean theReadTessellatedWhenNoBRepOnly,
@@ -834,31 +797,27 @@ void StepToTopoDS_Builder::Init(const Handle(StepVisual_TessellatedSolid)& theTS
   StepToTopoDS_DataMapOfTRI aMap;
   aTool.Init(aMap, theTP);
 
-  StepToTopoDS_NMTool dummyNMTool;
-  aTranSolid.Init(theTSo, theTP, aTool, dummyNMTool, theReadTessellatedWhenNoBRepOnly, 
+  StepToTopoDS_NMTool aDummyNMTool;
+  aTranSolid.Init(theTSo, theTP, aTool, aDummyNMTool, theReadTessellatedWhenNoBRepOnly,
                   theHasGeom, theLocalFactors, theProgress);
 
-  if (aTranSolid.IsDone()) 
-  {
-    TopoDS_Shape aS = aTranSolid.Value();
-    TransferBRep::SetShapeResult(theTP, theTSo, aS);
-    myResult = TopoDS::Solid(aS);
-    myError = StepToTopoDS_BuilderDone;
-    done = Standard_True;
-  }
-  else
+  if (!aTranSolid.IsDone())
   {
     theTP->AddWarning(theTSo, " TessellatedSolid not mapped to TopoDS");
     myError = StepToTopoDS_BuilderOther;
-    done = Standard_True;
+    done = Standard_False;
+    return;
   }
+  TopoDS_Shape aS = aTranSolid.Value();
+  myResult = TopoDS::Solid(aS);
+  myError = StepToTopoDS_BuilderDone;
+  done = Standard_True;
 }
 
 // ============================================================================
-// Method  : StepToTopoDS_Builder::Init
+// Method  : Init
 // Purpose : Builds a TopoDS_Shell from StepVisual_TessellatedShell
 // ============================================================================
-
 void StepToTopoDS_Builder::Init(const Handle(StepVisual_TessellatedShell)& theTSh,
                                 const Handle(Transfer_TransientProcess)& theTP,
                                 const Standard_Boolean theReadTessellatedWhenNoBRepOnly,
@@ -874,31 +833,27 @@ void StepToTopoDS_Builder::Init(const Handle(StepVisual_TessellatedShell)& theTS
   StepToTopoDS_DataMapOfTRI aMap;
   aTool.Init(aMap, theTP);
 
-  StepToTopoDS_NMTool dummyNMTool;
-  aTranShell.Init(theTSh, aTool, dummyNMTool, theReadTessellatedWhenNoBRepOnly, 
+  StepToTopoDS_NMTool aDummyNMTool;
+  aTranShell.Init(theTSh, aTool, aDummyNMTool, theReadTessellatedWhenNoBRepOnly,
                   theHasGeom, theLocalFactors, theProgress);
 
-  if (aTranShell.IsDone()) 
-  {
-    TopoDS_Shape aS = aTranShell.Value();
-    TransferBRep::SetShapeResult(theTP, theTSh, aS);
-    myResult = TopoDS::Shell(aS);
-    myError = StepToTopoDS_BuilderDone;
-    done = Standard_True;
-  }
-  else 
+  if (!aTranShell.IsDone()) 
   {
     theTP->AddWarning(theTSh, " TessellatedShell not mapped to TopoDS");
     myError = StepToTopoDS_BuilderOther;
-    done = Standard_True;
+    done = Standard_False;
+    return;
   }
+  TopoDS_Shape aS = aTranShell.Value();
+  myResult = TopoDS::Shell(aS);
+  myError = StepToTopoDS_BuilderDone;
+  done = Standard_True;
 }
 
 // ============================================================================
-// Method  : StepToTopoDS_Builder::Init
+// Method  : Init
 // Purpose : Builds a TopoDS_Face from StepVisual_TessellatedFace
 // ============================================================================
-
 void StepToTopoDS_Builder::Init(const Handle(StepVisual_TessellatedFace)& theTF,
                                 const Handle(Transfer_TransientProcess)& theTP,
                                 const Standard_Boolean theReadTessellatedWhenNoBRepOnly,
@@ -913,23 +868,53 @@ void StepToTopoDS_Builder::Init(const Handle(StepVisual_TessellatedFace)& theTF,
   StepToTopoDS_DataMapOfTRI aMap;
   aTool.Init(aMap, theTP);
 
-  StepToTopoDS_NMTool dummyNMTool;
-  aTranFace.Init(theTF, aTool, dummyNMTool, theReadTessellatedWhenNoBRepOnly, theHasGeom, theLocalFactors);
-
-  if (aTranFace.IsDone()) 
+  StepToTopoDS_NMTool aDummyNMTool;
+  aTranFace.Init(theTF, aTool, aDummyNMTool, theReadTessellatedWhenNoBRepOnly, theHasGeom, theLocalFactors);
+  if (!aTranFace.IsDone()) 
   {
-    TopoDS_Shape aS = aTranFace.Value();
-    TransferBRep::SetShapeResult(theTP, theTF, aS);
-    myResult = TopoDS::Face(aS);
-    myError = StepToTopoDS_BuilderDone;
-    done = Standard_True;
+    theTP->AddWarning(theTF, " TessellatedFace not mapped to TopoDS");
+    myError = StepToTopoDS_BuilderOther;
+    done = Standard_False;
+    return;
   }
-  else 
+  TopoDS_Shape aS = aTranFace.Value();
+  myResult = TopoDS::Face(aS);
+  myError = StepToTopoDS_BuilderDone;
+  done = Standard_True;
+}
+
+// ============================================================================
+// Method  : Init
+// Purpose : Builds a TopoDS_Face from StepVisual_TessellatedSurfaceSet
+// ============================================================================
+void StepToTopoDS_Builder::Init(const Handle(StepVisual_TessellatedSurfaceSet)& theTSS,
+                                const Handle(Transfer_TransientProcess)& theTP,
+                                const StepData_Factors& theLocalFactors,
+                                Standard_Boolean& theHasGeom)
+{
+  StepToTopoDS_TranslateFace aTranFace;
+  aTranFace.SetPrecision(Precision());
+  aTranFace.SetMaxTol(MaxTol());
+
+  StepToTopoDS_Tool aTool;
+  StepToTopoDS_DataMapOfTRI aMap;
+  aTool.Init(aMap, theTP);
+
+  StepToTopoDS_NMTool aDummyNMTool;
+  aTranFace.Init(theTSS, aTool, aDummyNMTool, theLocalFactors);
+  theHasGeom = Standard_False;
+
+  if ( !aTranFace.IsDone() )
   {
-    theTP->AddWarning(theTF, " TessellatedFace not mapped to TopoDS");
+    theTP->AddWarning(theTSS, " TessellatedSurfaceSet not mapped to TopoDS");
     myError = StepToTopoDS_BuilderOther;
-    done = Standard_True;
+    done = Standard_False;
+    return;
   }
+  TopoDS_Shape aS = aTranFace.Value();
+  myResult = TopoDS::Face(aS);
+  myError = StepToTopoDS_BuilderDone;
+  done = Standard_True;
 }
 
 // ============================================================================
index 1388fc47799b3a31a9b892261b3e06fdb7d6b991..4453fb377c1823a44251d6282bc2b966ab2fa6ae 100644 (file)
@@ -39,6 +39,7 @@ class StepShape_FaceBasedSurfaceModel;
 class StepVisual_TessellatedFace;
 class StepVisual_TessellatedShell;
 class StepVisual_TessellatedSolid;
+class StepVisual_TessellatedSurfaceSet;
 class Transfer_ActorOfTransientProcess;
 
 
@@ -52,23 +53,23 @@ public:
   
   Standard_EXPORT StepToTopoDS_Builder();
   
-  Standard_EXPORT void Init (const Handle(StepShape_ManifoldSolidBrep)& S,
-                             const Handle(Transfer_TransientProcess)& TP,
+  Standard_EXPORT void Init (const Handle(StepShape_ManifoldSolidBrep)& theManifoldSolid,
+                             const Handle(Transfer_TransientProcess)& theTP,
                              const StepData_Factors& theLocalFactors,
                              const Message_ProgressRange& theProgress = Message_ProgressRange());
   
-  Standard_EXPORT void Init (const Handle(StepShape_BrepWithVoids)& S,
-                             const Handle(Transfer_TransientProcess)& TP,
+  Standard_EXPORT void Init (const Handle(StepShape_BrepWithVoids)& theBRepWithVoids,
+                             const Handle(Transfer_TransientProcess)& theTP,
                              const StepData_Factors& theLocalFactors,
                              const Message_ProgressRange& theProgress = Message_ProgressRange());
   
-  Standard_EXPORT void Init (const Handle(StepShape_FacetedBrep)& S,
-                             const Handle(Transfer_TransientProcess)& TP,
+  Standard_EXPORT void Init (const Handle(StepShape_FacetedBrep)& theFB,
+                             const Handle(Transfer_TransientProcess)& theTP,
                              const StepData_Factors& theLocalFactors,
                              const Message_ProgressRange& theProgress = Message_ProgressRange());
   
-  Standard_EXPORT void Init (const Handle(StepShape_FacetedBrepAndBrepWithVoids)& S,
-                             const Handle(Transfer_TransientProcess)& TP,
+  Standard_EXPORT void Init (const Handle(StepShape_FacetedBrepAndBrepWithVoids)& theFBABWV,
+                             const Handle(Transfer_TransientProcess)& theTP,
                              const StepData_Factors& theLocalFactors,
                              const Message_ProgressRange& theProgress = Message_ProgressRange());
   
@@ -112,6 +113,11 @@ public:
                              const Standard_Boolean theReadTessellatedWhenNoBRepOnly,
                              Standard_Boolean& theHasGeom,
                              const StepData_Factors& theLocalFactors);
+
+  Standard_EXPORT void Init (const Handle(StepVisual_TessellatedSurfaceSet)& theTSS,
+                             const Handle(Transfer_TransientProcess)& theTP,
+                             const StepData_Factors& theLocalFactors,
+                             Standard_Boolean& theHasGeom);
   
   Standard_EXPORT const TopoDS_Shape& Value() const;
   
index deb798e4277b6cac4fda7640fa0948cda5533413..c6e70f83cdc2570c2312d54d94c0dae36cff74f6 100644 (file)
@@ -84,6 +84,8 @@
 #include <StepGeom_ToroidalSurface.hxx>
 #include <StepVisual_TriangulatedFace.hxx>
 #include <StepVisual_ComplexTriangulatedFace.hxx>
+#include <StepVisual_TriangulatedSurfaceSet.hxx>
+#include <StepVisual_ComplexTriangulatedSurfaceSet.hxx>
 
 //#3 rln 16/02/98
 //#include <GeomAdaptor_Curve.hxx>
 //:d4
 // To proceed with I-DEAS-like STP (ssv; 15.11.2010)
 //#define DEBUG
+
+namespace {
+  // ============================================================================
+  // Method  : SetNodes
+  // Purpose : Set nodes to the triangulation from an array
+  // ============================================================================
+  static void SetNodes(const Handle(Poly_Triangulation)& theMesh,
+                       Handle(TColgp_HArray1OfXYZ)& theNodes,
+                       Handle(TColStd_HArray1OfInteger)& thePnindices,
+                       const Standard_Real theLengthFactor)
+  {
+    //const Standard_Real aLF = StepData_GlobalFactors::Intance().LengthFactor();
+    for (Standard_Integer aPnIndex = 1; aPnIndex <= theMesh->NbNodes(); ++aPnIndex)
+    {
+      const gp_XYZ& aPoint = theNodes->Value(thePnindices->Value(aPnIndex));
+      theMesh->SetNode(aPnIndex, theLengthFactor * aPoint);
+    }
+  }
+
+  // ============================================================================
+  // Method  : SetNormals
+  // Purpose : Set normals to the triangulation from an array
+  // ============================================================================
+  static void SetNormals(const Handle(Poly_Triangulation)& theMesh,
+                         const Handle(TColStd_HArray2OfReal)& theNormals,
+                         const Standard_Integer theNormNum,
+                         const Standard_Integer theNumPnindex)
+  {
+    if (theNormals->RowLength() != 3)
+    {
+      return;
+    }
+    gp_XYZ aNorm;
+    if (theNormNum == 1)
+    {
+      aNorm.SetX(theNormals->Value(1, 1));
+      aNorm.SetY(theNormals->Value(1, 2));
+      aNorm.SetZ(theNormals->Value(1, 3));
+      for (Standard_Integer aPnIndex = 1; aPnIndex <= theNumPnindex; ++aPnIndex)
+      {
+        theMesh->SetNormal(aPnIndex, aNorm);
+      }
+    }
+    else if (theNumPnindex == theNormNum)
+    {
+      for (Standard_Integer aNormIndex = 1; aNormIndex <= theNormNum; ++aNormIndex)
+      {
+        aNorm.SetX(theNormals->Value(aNormIndex, 1));
+        aNorm.SetY(theNormals->Value(aNormIndex, 2));
+        aNorm.SetZ(theNormals->Value(aNormIndex, 3));
+        theMesh->SetNormal(aNormIndex, aNorm);
+      }
+    }
+  }
+
+  // ============================================================================
+  // Method  : SetTriangles
+  // Purpose : Set triangles to the triangulation from an array
+  // ============================================================================
+  static void SetTriangles(const Handle(Poly_Triangulation)& theMesh,
+                           const Handle(TColStd_HArray2OfInteger) theTriangles,
+                           const Standard_Integer theTrianStripsNum,
+                           const Handle(TColStd_HArray2OfInteger)& theTrianStrips,
+                           const Standard_Integer theTrianFansNum,
+                           const Handle(TColStd_HArray2OfInteger)& theTrianFans)
+  {
+    if (theTrianStripsNum == 0 && theTrianFansNum == 0)
+    {
+      for (Standard_Integer aTrianIndex = 1; aTrianIndex <= theMesh->NbTriangles(); ++aTrianIndex)
+      {
+        theMesh->SetTriangle(aTrianIndex,
+                             Poly_Triangle(theTriangles->Value(aTrianIndex, 1),
+                                           theTriangles->Value(aTrianIndex, 2),
+                                           theTriangles->Value(aTrianIndex, 3)));
+      }
+    }
+    else
+    {
+      Standard_Integer aTriangleIndex = 1;
+      for (Standard_Integer aTrianStripIndex = 1; aTrianStripIndex <= theTrianStripsNum; ++aTrianStripIndex)
+      {
+        for (Standard_Integer anUCIndex = 3; anUCIndex <= theTrianStrips->UpperCol(); anUCIndex += 2)
+        {
+          if (theTrianStrips->Value(aTrianStripIndex, anUCIndex) != theTrianStrips->Value(aTrianStripIndex, anUCIndex - 2) &&
+            theTrianStrips->Value(aTrianStripIndex, anUCIndex) != theTrianStrips->Value(aTrianStripIndex, anUCIndex - 1))
+          {
+            theMesh->SetTriangle(aTriangleIndex++,
+                                 Poly_Triangle(theTrianStrips->Value(aTrianStripIndex, anUCIndex - 2),
+                                               theTrianStrips->Value(aTrianStripIndex, anUCIndex),
+                                               theTrianStrips->Value(aTrianStripIndex, anUCIndex - 1)));
+          }
+        }
+        for (Standard_Integer anUCIndex = 4; anUCIndex <= theTrianStrips->UpperCol(); anUCIndex += 2)
+        {
+          if (theTrianStrips->Value(aTrianStripIndex, anUCIndex) != theTrianStrips->Value(aTrianStripIndex, anUCIndex - 2)
+              && theTrianStrips->Value(aTrianStripIndex, anUCIndex) != theTrianStrips->Value(aTrianStripIndex, anUCIndex - 1))
+          {
+            theMesh->SetTriangle(aTriangleIndex++,
+                                 Poly_Triangle(theTrianStrips->Value(aTrianStripIndex, anUCIndex - 2),
+                                               theTrianStrips->Value(aTrianStripIndex, anUCIndex - 1),
+                                               theTrianStrips->Value(aTrianStripIndex, anUCIndex)));
+          }
+        }
+      }
+      for (Standard_Integer aTrianFanIndex = 1; aTrianFanIndex <= theTrianFansNum; ++aTrianFanIndex)
+      {
+        for (Standard_Integer anUCIndex = 3; anUCIndex <= theTrianFans->UpperCol(); ++anUCIndex)
+        {
+          if (theTrianFans->Value(aTrianFanIndex, anUCIndex) != theTrianFans->Value(aTrianFanIndex, anUCIndex - 2)
+              && theTrianFans->Value(aTrianFanIndex, anUCIndex - 1) != theTrianFans->Value(aTrianFanIndex, anUCIndex - 2))
+          {
+            theMesh->SetTriangle(aTriangleIndex++,
+                                 Poly_Triangle(theTrianStrips->Value(aTrianFanIndex, anUCIndex - 2),
+                                               theTrianStrips->Value(aTrianFanIndex, anUCIndex - 1),
+                                               theTrianStrips->Value(aTrianFanIndex, anUCIndex)));
+          }
+        }
+      }
+    }
+  }
+
+  // ============================================================================
+// Method  : SetTriangles
+// Purpose : Set triangles to the triangulation from an array
+// ============================================================================
+  static void SetTriangles(const Handle(Poly_Triangulation)& theMesh,
+                           const Handle(TColStd_HArray2OfInteger) theTriangles,
+                           const Standard_Integer theTrianStripsNum,
+                           const Handle(TColStd_HArray1OfTransient)& theTrianStrips,
+                           const Standard_Integer theTrianFansNum,
+                           const Handle(TColStd_HArray1OfTransient)& theTrianFans)
+  {
+    if (theTrianStripsNum == 0 && theTrianFansNum == 0)
+    {
+      for (Standard_Integer aTrianIndex = 1; aTrianIndex <= theMesh->NbTriangles(); ++aTrianIndex)
+      {
+        theMesh->SetTriangle(aTrianIndex, Poly_Triangle(theTriangles->Value(aTrianIndex, 1),
+                                                        theTriangles->Value(aTrianIndex, 2),
+                                                        theTriangles->Value(aTrianIndex, 3)));
+      }
+    }
+    else
+    {
+      Standard_Integer aTriangleIndex = 1;
+      for (Standard_Integer aTrianStripIndex = 1; aTrianStripIndex <= theTrianStripsNum; ++aTrianStripIndex)
+      {
+        Handle(TColStd_HArray1OfInteger) aTriangleStrip = Handle(TColStd_HArray1OfInteger)::DownCast(theTrianStrips->Value(aTrianStripIndex));
+        for (Standard_Integer anIndex = 3; anIndex <= aTriangleStrip->Length(); anIndex += 2)
+        {
+          if (aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 2) &&
+              aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 1))
+          {
+            theMesh->SetTriangle(aTriangleIndex++, Poly_Triangle(aTriangleStrip->Value(anIndex - 2),
+                                                                 aTriangleStrip->Value(anIndex),
+                                                                 aTriangleStrip->Value(anIndex - 1)));
+          }
+        }
+        for (Standard_Integer anIndex = 4; anIndex <= aTriangleStrip->Length(); anIndex += 2)
+        {
+          if (aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 2) &&
+              aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 1))
+          {
+            theMesh->SetTriangle(aTriangleIndex++, Poly_Triangle(aTriangleStrip->Value(anIndex - 2),
+                                                                 aTriangleStrip->Value(anIndex - 1),
+                                                                 aTriangleStrip->Value(anIndex)));
+          }
+        }
+      }
+      for (Standard_Integer aTrianFanIndex = 1; aTrianFanIndex <= theTrianFansNum; ++aTrianFanIndex)
+      {
+        Handle(TColStd_HArray1OfInteger) aTriangleFan = Handle(TColStd_HArray1OfInteger)::DownCast(theTrianFans->Value(aTrianFanIndex));
+        for (Standard_Integer anIndex = 3; anIndex <= aTriangleFan->Length(); ++anIndex)
+        {
+          if (aTriangleFan->Value(anIndex) != aTriangleFan->Value(anIndex - 2) &&
+              aTriangleFan->Value(anIndex - 1) != aTriangleFan->Value(anIndex - 2))
+          {
+            theMesh->SetTriangle(aTriangleIndex++, Poly_Triangle(aTriangleFan->Value(anIndex - 2),
+                                                                 aTriangleFan->Value(anIndex - 1),
+                                                                 aTriangleFan->Value(anIndex)));
+          }
+        }
+      }
+    }
+  }
+
+  // ============================================================================
+  // Method  : GetSimpleFaceElements
+  // Purpose : Get elements from simple face
+  // ============================================================================
+  template<class Type>
+  static void GetSimpleFaceElements(Type theFace,
+                                    Handle(TColgp_HArray1OfXYZ)& theNodes,
+                                    Handle(TColStd_HArray2OfReal)& theNormals,
+                                    Handle(TColStd_HArray2OfInteger)& theTriangles,
+                                    Standard_Integer& thePnIndNb,
+                                    Standard_Integer& theNormNb,
+                                    Standard_Integer& theTriNb,
+                                    Handle(TColStd_HArray1OfInteger)& thePnindices)
+  {
+    theNodes = theFace->Coordinates()->Points();
+    theNormals = theFace->Normals();
+    theTriangles = theFace->Triangles();
+    thePnIndNb = theFace->NbPnindex();
+    theNormNb = theFace->NbNormals();
+    theTriNb = theFace->NbTriangles();
+    thePnindices = new TColStd_HArray1OfInteger(1, thePnIndNb);
+    for (Standard_Integer anIndx = 1; anIndx <= thePnIndNb; ++anIndx)
+    {
+      thePnindices->SetValue(anIndx, theFace->PnindexValue(anIndx));
+    }
+  }
+
+  // ============================================================================
+  // Method  : GetComplexFaceElements
+  // Purpose : Get elements from complex face
+  // ============================================================================
+  template<class Type>
+  static void GetComplexFaceElements(Type theFace,
+                                     Handle(TColgp_HArray1OfXYZ)& theNodes,
+                                     Handle(TColStd_HArray2OfReal)& theNormals,
+                                     Handle(TColStd_HArray2OfInteger)& theTriangleStrips,
+                                     Handle(TColStd_HArray2OfInteger)& theTriangleFans,
+                                     Standard_Integer& thePnIndNb,
+                                     Standard_Integer& theNormNb,
+                                     Standard_Integer& theTriStripsNb,
+                                     Standard_Integer& theTriFansNb,
+                                     Handle(TColStd_HArray1OfInteger)& thePnindices)
+  {
+    theNodes = theFace->Coordinates()->Points();
+    theNormals = theFace->Normals();
+    theTriangleStrips = theFace->TriangleStrips();
+    theTriangleFans = theFace->TriangleFans();
+    thePnIndNb = theFace->NbPnindex();
+    theNormNb = theFace->NbNormals();
+    theTriStripsNb = theFace->NbTriangleStrips();
+    theTriFansNb = theFace->NbTriangleFans();
+    thePnindices = new TColStd_HArray1OfInteger(1, thePnIndNb);
+    for (Standard_Integer anIndx = 1; anIndx <= thePnIndNb; ++anIndx)
+    {
+      thePnindices->SetValue(anIndx, theFace->PnindexValue(anIndx));
+    }
+  }
+
+  // ============================================================================
+// Method  : GetComplexFaceSetElements
+// Purpose : Get elements from complex face
 // ============================================================================
-// Method  : StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace
+  template<class Type>
+  static void GetComplexFaceSetElements(Type theFace,
+                                        Handle(TColgp_HArray1OfXYZ)& theNodes,
+                                        Handle(TColStd_HArray2OfReal)& theNormals,
+                                        Handle(TColStd_HArray1OfTransient)& theTriangleStrips,
+                                        Handle(TColStd_HArray1OfTransient)& theTriangleFans,
+                                        Standard_Integer& thePnIndNb,
+                                        Standard_Integer& theNormNb,
+                                        Standard_Integer& theTriStripsNb,
+                                        Standard_Integer& theTriFansNb,
+                                        Handle(TColStd_HArray1OfInteger)& thePnindices)
+  {
+    theNodes = theFace->Coordinates()->Points();
+    theNormals = theFace->Normals();
+    theTriangleStrips = theFace->TriangleStrips();
+    theTriangleFans = theFace->TriangleFans();
+    thePnIndNb = theFace->NbPnindex();
+    theNormNb = theFace->NbNormals();
+    theTriStripsNb = theFace->NbTriangleStrips();
+    theTriFansNb = theFace->NbTriangleFans();
+    thePnindices = new TColStd_HArray1OfInteger(1, thePnIndNb);
+    for (Standard_Integer anIndx = 1; anIndx <= thePnIndNb; ++anIndx)
+    {
+      thePnindices->SetValue(anIndx, theFace->PnindexValue(anIndx));
+    }
+  }
+
+  // ============================================================================
+  // Method  : CreatePolyTriangulation
+  // Purpose : Create PolyTriangulation
+  // ============================================================================
+  static Handle(Poly_Triangulation) CreatePolyTriangulation(const Handle(StepVisual_TessellatedItem)& theTI,
+                                                            const StepData_Factors& theLocalFactors)
+  {
+    Handle(Poly_Triangulation) aMesh;
+    if (theTI.IsNull())
+    {
+      return Handle(Poly_Triangulation)();
+    }
+
+    Handle(TColgp_HArray1OfXYZ) aNodes;
+    Handle(TColStd_HArray2OfReal) aNormals;
+    Handle(TColStd_HArray2OfInteger) aTriangles;
+    Standard_Integer aNumPnindex = 0;
+    Standard_Integer aNormNum = 0;
+    Standard_Integer aTrianNum = 0;
+    Handle(TColStd_HArray1OfInteger) aPnindices;
+
+    Handle(TColStd_HArray2OfInteger) aTriaStrips;
+    Handle(TColStd_HArray2OfInteger) aTriaFans;
+    Standard_Integer aTrianStripsNum = 0;
+    Standard_Integer aTrianFansNum = 0;
+
+    Handle(TColStd_HArray1OfTransient) aTriaStrips1;
+    Handle(TColStd_HArray1OfTransient) aTriaFans1;
+
+    if (theTI->IsKind(STANDARD_TYPE(StepVisual_TriangulatedFace)))
+    {
+      Handle(StepVisual_TriangulatedFace) aTF = Handle(StepVisual_TriangulatedFace)::DownCast(theTI);
+      GetSimpleFaceElements(aTF, aNodes, aNormals, aTriangles, aNumPnindex, aNormNum, aTrianNum, aPnindices);
+    }
+    else if (theTI->IsKind(STANDARD_TYPE(StepVisual_TriangulatedSurfaceSet)))
+    {
+      Handle(StepVisual_TriangulatedSurfaceSet) aTSS = Handle(StepVisual_TriangulatedSurfaceSet)::DownCast(theTI);
+      GetSimpleFaceElements(aTSS, aNodes, aNormals, aTriangles, aNumPnindex, aNormNum, aTrianNum, aPnindices);
+    }
+    else if (theTI->IsKind(STANDARD_TYPE(StepVisual_ComplexTriangulatedFace)))
+    {
+      Handle(StepVisual_ComplexTriangulatedFace) aTF = Handle(StepVisual_ComplexTriangulatedFace)::DownCast(theTI);
+      GetComplexFaceElements(aTF, aNodes, aNormals, aTriaStrips, aTriaFans, aNumPnindex, aNormNum, aTrianStripsNum, aTrianFansNum, aPnindices);
+    }
+    else if (theTI->IsKind(STANDARD_TYPE(StepVisual_ComplexTriangulatedSurfaceSet)))
+    {
+      Handle(StepVisual_ComplexTriangulatedSurfaceSet) aTSS = Handle(StepVisual_ComplexTriangulatedSurfaceSet)::DownCast(theTI);
+      GetComplexFaceSetElements(aTSS, aNodes, aNormals, aTriaStrips1, aTriaFans1, aNumPnindex, aNormNum, aTrianStripsNum, aTrianFansNum, aPnindices);
+    }
+    else
+    {
+      return Handle(Poly_Triangulation)();
+    }
+
+    const Standard_Boolean aHasUVNodes = Standard_False;
+    const Standard_Boolean aHasNormals = (aNormNum > 0);
+
+    if (aTrianStripsNum == 0 && aTrianFansNum == 0)
+    {
+      aMesh = new Poly_Triangulation(aNumPnindex, aTrianNum, aHasUVNodes, aHasNormals);
+    }
+    else
+    {
+      Standard_Integer aNbTriaStrips = 0;
+      Standard_Integer aNbTriaFans = 0;
+      if (aTriaStrips1.IsNull() && aTriaFans1.IsNull())
+      {
+        for (Standard_Integer aTrianStripIndex = 1; aTrianStripIndex <= aTrianStripsNum; ++aTrianStripIndex)
+        {
+          for (Standard_Integer anUCIndex = 3; anUCIndex <= aTriaStrips->UpperCol(); anUCIndex += 2)
+          {
+            if (aTriaStrips->Value(aTrianStripIndex, anUCIndex) != aTriaStrips->Value(aTrianStripIndex, anUCIndex - 2) &&
+                aTriaStrips->Value(aTrianStripIndex, anUCIndex) != aTriaStrips->Value(aTrianStripIndex, anUCIndex - 1))
+              ++aNbTriaStrips;
+          }
+          for (Standard_Integer anUCIndex = 4; anUCIndex <= aTriaStrips->UpperCol(); anUCIndex += 2)
+          {
+            if (aTriaStrips->Value(aTrianStripIndex, anUCIndex) != aTriaStrips->Value(aTrianStripIndex, anUCIndex - 2) &&
+                aTriaStrips->Value(aTrianStripIndex, anUCIndex) != aTriaStrips->Value(aTrianStripIndex, anUCIndex - 1))
+              ++aNbTriaStrips;
+          }
+        }
+
+        for (Standard_Integer aTrianFanIndex = 1; aTrianFanIndex <= aTrianFansNum; ++aTrianFanIndex)
+        {
+          Standard_Integer aFirst = aTriaStrips->Value(aTrianFanIndex, 1);
+          for (Standard_Integer anUCIndex = 3; anUCIndex <= aTriaStrips->UpperCol(); ++anUCIndex)
+          {
+            if (aTriaStrips->Value(aTrianFanIndex, anUCIndex) != aFirst &&
+                aTriaStrips->Value(aTrianFanIndex, anUCIndex - 1) != aFirst)
+              ++aNbTriaFans;
+          }
+        }
+      }
+      else
+      {
+        for (Standard_Integer aTrianStripIndex = 1; aTrianStripIndex <= aTrianStripsNum; ++aTrianStripIndex)
+        {
+          Handle(TColStd_HArray1OfInteger) aTriangleStrip = Handle(TColStd_HArray1OfInteger)::DownCast(aTriaStrips1->Value(aTrianStripIndex));
+          for (Standard_Integer anIndex = 3; anIndex <= aTriangleStrip->Length(); anIndex += 2)
+          {
+            if (aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 2) &&
+                aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 1))
+              ++aNbTriaStrips;
+          }
+          for (Standard_Integer anIndex = 4; anIndex <= aTriangleStrip->Length(); anIndex += 2)
+          {
+            if (aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 2) &&
+                aTriangleStrip->Value(anIndex) != aTriangleStrip->Value(anIndex - 1))
+              ++aNbTriaStrips;
+          }
+        }
+
+        for (Standard_Integer aTrianFanIndex = 1; aTrianFanIndex <= aTrianFansNum; ++aTrianFanIndex)
+        {
+          Handle(TColStd_HArray1OfInteger) aTriangleFan = Handle(TColStd_HArray1OfInteger)::DownCast(aTriaFans1->Value(aTrianFansNum));
+          aNbTriaFans += aTriangleFan->Length() - 2;
+        }
+      }
+
+      aMesh = new Poly_Triangulation(aNumPnindex, aNbTriaStrips + aNbTriaFans, aHasUVNodes, aHasNormals);
+    }
+
+    SetNodes(aMesh, aNodes, aPnindices, theLocalFactors.LengthFactor());
+
+    if (aHasNormals)
+    {
+      SetNormals(aMesh, aNormals, aNormNum, aNumPnindex);
+    }
+
+    if (aTriaStrips1.IsNull() && aTriaFans1.IsNull())
+    {
+      SetTriangles(aMesh, aTriangles, aTrianStripsNum, aTriaStrips, aTrianFansNum, aTriaFans);
+    }
+    else
+    {
+      SetTriangles(aMesh, aTriangles, aTrianStripsNum, aTriaStrips1, aTrianFansNum, aTriaFans1);
+    }
+
+    return aMesh;
+  }
+}
+
+// ============================================================================
+// Method  : StepToTopoDS_TranslateFace
 // Purpose : Empty Constructor
 // ============================================================================
 StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace()
@@ -106,10 +525,9 @@ StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace()
 }
 
 // ============================================================================
-// Method  : StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace
+// Method  : StepToTopoDS_TranslateFace
 // Purpose : Constructor with a FaceSurface and a Tool
 // ============================================================================
-
 StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace(const Handle(StepShape_FaceSurface)& FS,
                                                        StepToTopoDS_Tool& T,
                                                        StepToTopoDS_NMTool& NMTool,
@@ -119,11 +537,10 @@ StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace(const Handle(StepShape_Fa
 }
 
 // ============================================================================
-// Method  : StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace
+// Method  : StepToTopoDS_TranslateFace
 // Purpose : Constructor with either TriangulatedFace or 
 //           ComplexTriangulatedFace and a Tool
 // ============================================================================
-
 StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace(const Handle(StepVisual_TessellatedFace)& theTF,
                                                        StepToTopoDS_Tool& theTool,
                                                        StepToTopoDS_NMTool& theNMTool,
@@ -134,11 +551,23 @@ StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace(const Handle(StepVisual_T
   Init(theTF, theTool, theNMTool, theReadTessellatedWhenNoBRepOnly, theHasGeom, theLocalFactors);
 }
 
+// ============================================================================
+// Method  : StepToTopoDS_TranslateFace
+// Purpose : Constructor with either TriangulatedSurfaceSet or 
+//           ComplexTriangulatedSurfaceSet and a Tool
+// ============================================================================
+StepToTopoDS_TranslateFace::StepToTopoDS_TranslateFace(const Handle(StepVisual_TessellatedSurfaceSet)& theTSS,
+                                                       StepToTopoDS_Tool& theTool,
+                                                       StepToTopoDS_NMTool& theNMTool,
+                                                       const StepData_Factors& theLocalFactors)
+{
+  Init(theTSS, theTool, theNMTool, theLocalFactors);
+}
+
 // ============================================================================
 // Method  : Init
 // Purpose : Init with a FaceSurface and a Tool
 // ============================================================================
-
 static inline Standard_Boolean isReversed(const Handle(StepGeom_Surface)& theStepSurf)
 {
   Handle(StepGeom_ToroidalSurface) aStepTorSur;
@@ -155,7 +584,6 @@ static inline Standard_Boolean isReversed(const Handle(StepGeom_Surface)& theSte
 // Method  : Init
 // Purpose : Init with a FaceSurface and a Tool
 // ============================================================================
-
 void StepToTopoDS_TranslateFace::Init(const Handle(StepShape_FaceSurface)& FS,
                                       StepToTopoDS_Tool& aTool,
                                       StepToTopoDS_NMTool& NMTool,
@@ -174,7 +602,6 @@ void StepToTopoDS_TranslateFace::Init(const Handle(StepShape_FaceSurface)& FS,
   // ----------------------------------------------
   // Map the Face Geometry and create a TopoDS_Face
   // ----------------------------------------------
-  
   Handle(StepGeom_Surface) StepSurf = FS->FaceGeometry();
 
    // sln 01.10.2001 BUC61003. If corresponding entity was read with error StepSurface may be NULL. In this case we exit from function
@@ -233,7 +660,6 @@ void StepToTopoDS_TranslateFace::Init(const Handle(StepShape_FaceSurface)& FS,
   // ----------------------------------
   // Iterate on each FaceBounds (Wires)
   // ----------------------------------
-  
   Handle(StepShape_FaceBound) FaceBound;
   Handle(StepShape_Loop)      Loop;
   
@@ -313,7 +739,6 @@ void StepToTopoDS_TranslateFace::Init(const Handle(StepShape_FaceSurface)& FS,
   // ----------------------
   // The Loop is a PolyLoop
   // ----------------------
-    
     else if (Loop->IsKind(STANDARD_TYPE(StepShape_PolyLoop))) {
 //:S4136      STF.Closed() = Standard_False;
       Handle(StepShape_PolyLoop) PL = Handle(StepShape_PolyLoop)::DownCast(Loop);
@@ -334,7 +759,6 @@ void StepToTopoDS_TranslateFace::Init(const Handle(StepShape_FaceSurface)& FS,
     // -----------------------
     // The Loop is an EdgeLoop
     // -----------------------
-    
   else if (Loop->IsKind(STANDARD_TYPE(StepShape_EdgeLoop))) {
     //:S4136      if (STF.Closed()) {
     //:S4136   Handle(StepShape_EdgeLoop) EL = 
@@ -367,7 +791,6 @@ void StepToTopoDS_TranslateFace::Init(const Handle(StepShape_FaceSurface)& FS,
       // -----------------------------
       // The Wire is added to the Face      
       // -----------------------------
-
       B.Add(F, W);
     }
     else {
@@ -411,7 +834,6 @@ void StepToTopoDS_TranslateFace::Init(const Handle(StepShape_FaceSurface)& FS,
 // Purpose : Init with either StepVisual_TriangulatedFace or 
 //           StepVisual_ComplexTriangulatedFace and a Tool
 // ============================================================================
-
 void StepToTopoDS_TranslateFace::Init(const Handle(StepVisual_TessellatedFace)& theTF,
                                       StepToTopoDS_Tool& theTool,
                                       StepToTopoDS_NMTool& theNMTool,
@@ -481,175 +903,76 @@ void StepToTopoDS_TranslateFace::Init(const Handle(StepVisual_TessellatedFace)&
 }
 
 // ============================================================================
-// Method  : createMesh 
-// Purpose : creates a Poly_Triangulation from TriangulatedFace
+// Method  : Init
+// Purpose : Init with either StepVisual_TriangulatedSurfaceSet or
+//           StepVisual_ComplexTriangulatedSurfaceSet and a Tool
 // ============================================================================
-
-Handle(Poly_Triangulation) 
-StepToTopoDS_TranslateFace::createMesh(const Handle(StepVisual_TriangulatedFace)& theTF,
-                                       const StepData_Factors& theLocalFactors) const
+void StepToTopoDS_TranslateFace::Init(const Handle(StepVisual_TessellatedSurfaceSet)& theTSS,
+                                      StepToTopoDS_Tool& theTool,
+                                      StepToTopoDS_NMTool& theNMTool,
+                                      const StepData_Factors& theLocalFactors)
 {
-  Handle(StepVisual_CoordinatesList) aCoords = theTF->Coordinates();
-  Handle(TColgp_HArray1OfXYZ) aNodes = aCoords->Points();
-  Handle(TColStd_HArray2OfInteger) aTriangles = theTF->Triangles();
-  const Standard_Boolean aHasUVNodes = Standard_False;
-  const Standard_Boolean aHasNormals = (theTF->NbNormals() > 0);
-  Handle(Poly_Triangulation) aMesh = new Poly_Triangulation(theTF->NbPnindex(), theTF->NbTriangles(), aHasUVNodes, aHasNormals);
-
-  const Standard_Real aLF = theLocalFactors.LengthFactor();
-  for (Standard_Integer j = 1; j <= theTF->NbPnindex(); ++j)
+  if (theTSS.IsNull())
+    return;
+
+  Handle(Transfer_TransientProcess) aTP = theTool.TransientProcess();
+  BRep_Builder aB;
+  TopoDS_Face aF;
+  aB.MakeFace(aF);
+
+  Handle(Poly_Triangulation) aMesh;
+  if (DeclareAndCast(StepVisual_TriangulatedSurfaceSet, aTriaSS, theTSS))
   {
-    const gp_XYZ& aPoint = aNodes->Value(theTF->PnindexValue(j));
-    aMesh->SetNode(j, aPoint * aLF);
+    aMesh = createMesh(aTriaSS, theLocalFactors);
   }
-
-  for (Standard_Integer k = 1; k <= theTF->NbTriangles(); ++k)
+  else if (DeclareAndCast(StepVisual_ComplexTriangulatedSurfaceSet, aCompTriaSS, theTSS))
   {
-    aMesh->SetTriangle(k, Poly_Triangle(aTriangles->Value(k, 1), aTriangles->Value(k, 2), aTriangles->Value(k, 3)));
+    aMesh = createComplexMesh(aCompTriaSS, theLocalFactors);
   }
-
-  if (aHasNormals) 
+  else
   {
-    Handle(TColStd_HArray2OfReal) aNormals = theTF->Normals();
-    gp_XYZ aNorm;
-    if (theTF->NbNormals() == 1)
-    {
-      aNorm.SetX(aNormals->Value(1, 1));
-      aNorm.SetY(aNormals->Value(1, 2));
-      aNorm.SetZ(aNormals->Value(1, 3));
-      for (Standard_Integer i = 1; i <= theTF->NbPnindex(); ++i)
-      {
-        aMesh->SetNormal(i, aNorm);
-      }
-    }
-    else
-    {
-      for (Standard_Integer i = 1; i <= theTF->NbNormals(); ++i)
-      {
-        aNorm.SetX(aNormals->Value(i, 1));
-        aNorm.SetY(aNormals->Value(i, 2));
-        aNorm.SetZ(aNormals->Value(i, 3));
-        aMesh->SetNormal(i, aNorm);
-      }
-    }
+    aTP->AddWarning(theTSS, " Triangulated or ComplexTriangulated entity is supported only.");
+    return;
+  }
+  if (aMesh.IsNull())
+  {
+    aTP->AddWarning(theTSS, " Poly triangulation is not set to TopoDS face.");
+    return;
   }
+  aB.UpdateFace(aF, aMesh);
+  if (theNMTool.IsActive())
+    theNMTool.Bind(theTSS, aF);
 
-  return aMesh;
+  myResult = aF;
+  myError = StepToTopoDS_TranslateFaceDone;
+  done = Standard_True;
 }
 
 // ============================================================================
 // Method  : createMesh 
-// Purpose : creates a Poly_Triangulation from ComplexTriangulatedFace
+// Purpose : creates a Poly_Triangulation from TriangulatedFace or TriangulatedSurfaceSet
 // ============================================================================
-
-Handle(Poly_Triangulation) 
-StepToTopoDS_TranslateFace::createMesh(const Handle(StepVisual_ComplexTriangulatedFace)& theTF,
-                                       const StepData_Factors& theLocalFactors) const
+Handle(Poly_Triangulation)
+  StepToTopoDS_TranslateFace::createMesh(const Handle(StepVisual_TessellatedItem)& theTI,
+                                         const StepData_Factors& theLocalFactors) const
 {
-  Handle(StepVisual_CoordinatesList) aCoords = theTF->Coordinates();
-  Handle(TColgp_HArray1OfXYZ) aNodes = aCoords->Points();
-  Handle(TColStd_HArray2OfInteger) aTriaStrips = theTF->TriangleStrips();
-  Handle(TColStd_HArray2OfInteger) aTriaFans = theTF->TriangleFans();
-  const Standard_Boolean aHasUVNodes = Standard_False;
-  const Standard_Boolean aHasNormals = (theTF->NbNormals() > 0);
-
-  Standard_Integer aNbTriaStrips = 0;
-  for (Standard_Integer i = 1; i <= theTF->NbTriangleStrips(); ++i)
-  {
-    for (Standard_Integer j = 3; j <= aTriaStrips->UpperCol(); j += 2)
-    {
-      if (aTriaStrips->Value(i, j) != aTriaStrips->Value(i, j - 2) &&
-        aTriaStrips->Value(i, j) != aTriaStrips->Value(i, j - 1))
-        ++aNbTriaStrips;
-    }
-    for (Standard_Integer j = 4; j <= aTriaStrips->UpperCol(); j += 2)
-    {
-      if (aTriaStrips->Value(i, j) != aTriaStrips->Value(i, j - 2) &&
-        aTriaStrips->Value(i, j) != aTriaStrips->Value(i, j - 1))
-        ++aNbTriaStrips;
-    }
-  }
-
-  Standard_Integer aNbTriaFans = 0;
-  for (Standard_Integer i = 1; i <= theTF->NbTriangleFans(); ++i)
-  {
-    Standard_Integer v1 = aTriaStrips->Value(i, 1);
-    for (Standard_Integer j = 3; j <= aTriaStrips->UpperCol(); ++j)
-    {
-      if (aTriaStrips->Value(i, j) != v1 && aTriaStrips->Value(i, j - 1) != v1)
-        ++aNbTriaFans;
-    }
-  }
-
-  Handle(Poly_Triangulation) aMesh = new Poly_Triangulation(theTF->NbPnindex(), 
-    aNbTriaStrips + aNbTriaFans, aHasUVNodes, aHasNormals);
-
-  const Standard_Real aLF = theLocalFactors.LengthFactor();
-  for (Standard_Integer j = 1; j <= theTF->NbPnindex(); ++j)
-  {
-    const gp_XYZ& aPoint = aNodes->Value(theTF->PnindexValue(j));
-    aMesh->SetNode(j, aLF * aPoint);
-  }
-
-  Standard_Integer k = 1;
-  for (Standard_Integer i = 1; i <= theTF->NbTriangleStrips(); ++i)
-  {
-    for (Standard_Integer j = 3; j <= aTriaStrips->UpperCol(); j += 2)
-    {
-      if (aTriaStrips->Value(i, j) != aTriaStrips->Value(i, j - 2) &&
-        aTriaStrips->Value(i, j) != aTriaStrips->Value(i, j - 1))
-      {
-        aMesh->SetTriangle(k++, Poly_Triangle(aTriaStrips->Value(i, j - 2), 
-                                              aTriaStrips->Value(i, j), 
-                                              aTriaStrips->Value(i, j - 1)));
-      }
-    }
-    for (Standard_Integer j = 4; j <= aTriaStrips->UpperCol(); j += 2)
-    {
-      if (aTriaStrips->Value(i, j) != aTriaStrips->Value(i, j - 2) &&
-        aTriaStrips->Value(i, j) != aTriaStrips->Value(i, j - 1))
-      {
-        aMesh->SetTriangle(k++, Poly_Triangle(aTriaStrips->Value(i, j - 2),
-                                              aTriaStrips->Value(i, j - 1),
-                                              aTriaStrips->Value(i, j)));
-      }
-    }
-  }
-
-  if (aHasNormals)
-  {
-    Handle(TColStd_HArray2OfReal) aNormals = theTF->Normals();
-    gp_XYZ aNorm;
-    if (theTF->NbNormals() == 1)
-    {
-      aNorm.SetX(aNormals->Value(1, 1));
-      aNorm.SetY(aNormals->Value(1, 2));
-      aNorm.SetZ(aNormals->Value(1, 3));
-      for (Standard_Integer i = 1; i <= theTF->NbPnindex(); ++i)
-      {
-        aMesh->SetNormal(i, aNorm);
-      }
-    }
-    else
-    {
-      for (Standard_Integer i = 1; i <= theTF->NbNormals(); ++i)
-      {
-        aNorm.SetX(aNormals->Value(i, 1));
-        aNorm.SetY(aNormals->Value(i, 2));
-        aNorm.SetZ(aNormals->Value(i, 3));
-        aMesh->SetNormal(i, aNorm);
-      }
-    }
-  }
-
-  return aMesh;
+  return CreatePolyTriangulation(theTI, theLocalFactors);
 }
 
+// ============================================================================
+// Method  : createComplexMesh 
+// Purpose : creates a Poly_Triangulation from ComplexTriangulatedFace or ComplexTriangulatedSurfaceSet
+// ============================================================================
+Handle(Poly_Triangulation)
+  StepToTopoDS_TranslateFace::createComplexMesh(const Handle(StepVisual_TessellatedItem)& theTI,
+                                                const StepData_Factors& theLocalFactors) const
+{
+  return CreatePolyTriangulation(theTI, theLocalFactors);}
+
 // ============================================================================
 // Method  : Value 
 // Purpose : Return the mapped Shape
 // ============================================================================
-
 const TopoDS_Shape& StepToTopoDS_TranslateFace::Value() const 
 {
   StdFail_NotDone_Raise_if (!done, "StepToTopoDS_TranslateFace::Value() - no result");
@@ -660,7 +983,6 @@ const TopoDS_Shape& StepToTopoDS_TranslateFace::Value() const
 // Method  : Error
 // Purpose : Return the TranslateFace error
 // ============================================================================
-
 StepToTopoDS_TranslateFaceError StepToTopoDS_TranslateFace::Error() const
 {
   return myError;
index 1fc01453c283e994081a815f84c1ecc62a57ff3e..8955a89804ab9a11908d3d336ace3da4054d4809 100644 (file)
@@ -29,10 +29,11 @@ class StepData_Factors;
 class StepShape_FaceSurface;
 class StepToTopoDS_Tool;
 class StepToTopoDS_NMTool;
+class StepVisual_ComplexTriangulatedFace;
 class StepVisual_TessellatedFace;
+class StepVisual_TessellatedItem;
+class StepVisual_TessellatedSurfaceSet;
 class StepVisual_TriangulatedFace;
-class StepVisual_ComplexTriangulatedFace;
-
 
 class StepToTopoDS_TranslateFace  : public StepToTopoDS_Root
 {
@@ -54,6 +55,11 @@ public:
                                              const Standard_Boolean theReadTessellatedWhenNoBRepOnly,
                                              Standard_Boolean& theHasGeom,
                                              const StepData_Factors& theLocalFactors);
+
+  Standard_EXPORT StepToTopoDS_TranslateFace(const Handle(StepVisual_TessellatedSurfaceSet)& theTSS,
+                                             StepToTopoDS_Tool& theTool,
+                                             StepToTopoDS_NMTool& theNMTool,
+                                             const StepData_Factors& theLocalFactors);
   
   Standard_EXPORT void Init (const Handle(StepShape_FaceSurface)& FS,
                              StepToTopoDS_Tool& T,
@@ -66,28 +72,22 @@ public:
                              const Standard_Boolean theReadTessellatedWhenNoBRepOnly,
                              Standard_Boolean& theHasGeom,
                              const StepData_Factors& theLocalFactors);
+
+  Standard_EXPORT void Init(const Handle(StepVisual_TessellatedSurfaceSet)& theTSS,
+                            StepToTopoDS_Tool& theTool,
+                            StepToTopoDS_NMTool& theNMTool,
+                            const StepData_Factors& theLocalFactors);
   
   Standard_EXPORT const TopoDS_Shape& Value() const;
   
   Standard_EXPORT StepToTopoDS_TranslateFaceError Error() const;
 
-
-
-
-protected:
-
-
-
-
-
 private:
 
-  Handle(Poly_Triangulation) createMesh(const Handle(StepVisual_TriangulatedFace)& theTF,
-                                        const StepData_Factors& theLocalFactors) const;
-  Handle(Poly_Triangulation) createMesh(const Handle(StepVisual_ComplexTriangulatedFace)& theTF,
+  Handle(Poly_Triangulation) createMesh(const Handle(StepVisual_TessellatedItem)& theTI,
                                         const StepData_Factors& theLocalFactors) const;
-
-
+  Handle(Poly_Triangulation) createComplexMesh(const Handle(StepVisual_TessellatedItem)& theTI,
+                                               const StepData_Factors& theLocalFactors) const;
   StepToTopoDS_TranslateFaceError myError;
   TopoDS_Shape myResult;
 
@@ -95,9 +95,4 @@ private:
 };
 
 
-
-
-
-
-
 #endif // _StepToTopoDS_TranslateFace_HeaderFile
index ab69d5c5b3531c518336d2be231c847bc22520b0..b51fd1456dc350de8f11742a909d1bdb2e835cbf 100644 (file)
@@ -308,3 +308,5 @@ StepVisual_TessellatedWire.cxx
 StepVisual_TessellatedWire.hxx
 StepVisual_TriangulatedFace.cxx
 StepVisual_TriangulatedFace.hxx
+StepVisual_TriangulatedSurfaceSet.cxx
+StepVisual_TriangulatedSurfaceSet.hxx
index eb1a2b9f141d8ab56c32c9efba82263b2c3cf296..654b59c6658804fab4fc41bcb765cd228e385e42 100644 (file)
@@ -23,7 +23,8 @@ IMPLEMENT_STANDARD_RTTIEXT(StepVisual_TriangulatedFace, StepVisual_TessellatedFa
 //purpose  : 
 //=======================================================================
 
-StepVisual_TriangulatedFace::StepVisual_TriangulatedFace ()
+StepVisual_TriangulatedFace::StepVisual_TriangulatedFace()
+  : StepVisual_TessellatedFace()
 {
 }
 
index 151e8a534313a1b66c9fab8c48e336d022c235df..b91e5c74f2e7b70ea7f5dbd50085e28e3ff58095 100644 (file)
@@ -32,7 +32,7 @@ class StepVisual_TriangulatedFace : public StepVisual_TessellatedFace
 
 public :
 
-  //! default constructor
+  //! Default constructor
   Standard_EXPORT StepVisual_TriangulatedFace();
 
   //! Initialize all fields (own and inherited)
diff --git a/src/StepVisual/StepVisual_TriangulatedSurfaceSet.cxx b/src/StepVisual/StepVisual_TriangulatedSurfaceSet.cxx
new file mode 100644 (file)
index 0000000..59f0ef4
--- /dev/null
@@ -0,0 +1,78 @@
+// Copyright (c) Open CASCADE 2023
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <StepVisual_TriangulatedSurfaceSet.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(StepVisual_TriangulatedSurfaceSet, StepVisual_TessellatedSurfaceSet)
+
+//=======================================================================
+//function : StepVisual_TriangulatedSurfaceSet
+//purpose  :
+//=======================================================================
+StepVisual_TriangulatedSurfaceSet::StepVisual_TriangulatedSurfaceSet()
+{
+}
+
+//=======================================================================
+//function : Init
+//purpose  :
+//=======================================================================
+void StepVisual_TriangulatedSurfaceSet::Init(const Handle(TCollection_HAsciiString)& theRepresentationItemName,
+                                             const Handle(StepVisual_CoordinatesList)& theTessellatedSurfaceSetCoordinates,
+                                             const Standard_Integer theTessellatedSurfaceSetPnmax,
+                                             const Handle(TColStd_HArray2OfReal)& theTessellatedSurfaceSetNormals,
+                                             const Handle(TColStd_HArray1OfInteger)& thePnindex,
+                                             const Handle(TColStd_HArray2OfInteger)& theTriangles)
+{
+  StepVisual_TessellatedSurfaceSet::Init(theRepresentationItemName,
+                                         theTessellatedSurfaceSetCoordinates,
+                                         theTessellatedSurfaceSetPnmax,
+                                         theTessellatedSurfaceSetNormals);
+  myPnindex = thePnindex;
+  myTriangles = theTriangles;
+}
+
+//=======================================================================
+//function : NbPnindex
+//purpose  :
+//=======================================================================
+Standard_Integer StepVisual_TriangulatedSurfaceSet::NbPnindex() const
+{
+  if (myPnindex.IsNull())
+  {
+    return 0;
+  }
+  return myPnindex->Length();
+}
+
+//=======================================================================
+//function : PnindexValue
+//purpose  :
+//=======================================================================
+Standard_Integer StepVisual_TriangulatedSurfaceSet::PnindexValue(const Standard_Integer theNum) const
+{
+  return myPnindex->Value(theNum);
+}
+
+//=======================================================================
+//function : NbTriangles
+//purpose  :
+//=======================================================================
+Standard_Integer StepVisual_TriangulatedSurfaceSet::NbTriangles() const
+{
+  if (myTriangles.IsNull())
+  {
+    return 0;
+  }
+  return myTriangles->ColLength();
+}
diff --git a/src/StepVisual/StepVisual_TriangulatedSurfaceSet.hxx b/src/StepVisual/StepVisual_TriangulatedSurfaceSet.hxx
new file mode 100644 (file)
index 0000000..266ce14
--- /dev/null
@@ -0,0 +1,70 @@
+// Copyright (c) Open CASCADE 2023
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _StepVisual_TriangulatedSurfaceSet_HeaderFile_
+#define _StepVisual_TriangulatedSurfaceSet_HeaderFile_
+
+#include <Standard.hxx>
+#include <StepVisual_TessellatedSurfaceSet.hxx>
+
+#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_HArray2OfInteger.hxx>
+
+//! Representation of STEP entity TriangulatedSurfaceSet
+class StepVisual_TriangulatedSurfaceSet : public StepVisual_TessellatedSurfaceSet
+{
+public:
+  //! default constructor
+  Standard_EXPORT StepVisual_TriangulatedSurfaceSet();
+
+  //! Initialize all fields (own and inherited)
+  Standard_EXPORT void Init(const Handle(TCollection_HAsciiString)& theRepresentationItemName,
+                            const Handle(StepVisual_CoordinatesList)& theTessellatedFaceCoordinates,
+                            const Standard_Integer theTessellatedFacePnmax,
+                            const Handle(TColStd_HArray2OfReal)& theTessellatedFaceNormals,
+                            const Handle(TColStd_HArray1OfInteger)& thePnindex,
+                            const Handle(TColStd_HArray2OfInteger)& theTriangles);
+
+  //! Returns field Pnindex
+  const Handle(TColStd_HArray1OfInteger) Pnindex() const { return myPnindex; }
+
+  //! Sets field Pnindex
+  void SetPnindex(const Handle(TColStd_HArray1OfInteger)& thePnindex) { myPnindex = thePnindex; }
+
+  //! Returns number of Pnindex
+  Standard_EXPORT Standard_Integer NbPnindex() const;
+
+  //! Returns value of Pnindex by its num
+  Standard_EXPORT Standard_Integer PnindexValue(const Standard_Integer theNum) const;
+
+  //! Returns field Triangles
+  const Handle(TColStd_HArray2OfInteger) Triangles() const { return myTriangles; }
+
+  //! Sets field Triangles
+  void SetTriangles(const Handle(TColStd_HArray2OfInteger)& theTriangles)
+  {
+    myTriangles = theTriangles; 
+  }
+
+  //! Returns number of Triangles
+  Standard_EXPORT Standard_Integer NbTriangles() const;
+
+  DEFINE_STANDARD_RTTIEXT(StepVisual_TriangulatedSurfaceSet, StepVisual_TessellatedSurfaceSet)
+
+private:
+
+  Handle(TColStd_HArray1OfInteger) myPnindex;
+  Handle(TColStd_HArray2OfInteger) myTriangles;
+};
+
+#endif // _StepVisual_TriangulatedSurfaceSet_HeaderFile_
index 45fa6dbb4f6e9e6e6e576cbb1eb97a65af91cda9..c75e23aa3193082b9aa5f3319d5d5133fed11865 100644 (file)
@@ -36,7 +36,7 @@
 #include <Transfer_FinderProcess.hxx>
 
 // ============================================================================
-// Method  : TopoDSToStep_Builder::TopoDSToStep_Builder
+// Method  : TopoDSToStep_Builder
 // Purpose :
 // ============================================================================
 TopoDSToStep_Builder::TopoDSToStep_Builder()
@@ -46,10 +46,9 @@ TopoDSToStep_Builder::TopoDSToStep_Builder()
 }
 
 // ============================================================================
-// Method  : TopoDSToStep_Builder::TopoDSToStep_Builder
+// Method  : TopoDSToStep_Builder
 // Purpose :
 // ============================================================================
-
 TopoDSToStep_Builder::TopoDSToStep_Builder
 (const TopoDS_Shape& aShape,
   TopoDSToStep_Tool& aTool,
@@ -63,10 +62,9 @@ TopoDSToStep_Builder::TopoDSToStep_Builder
 }
 
 // ============================================================================
-// Method  : TopoDSToStep_Builder::Init
+// Method  : Init
 // Purpose :
 // ============================================================================
-
 void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
   TopoDSToStep_Tool& myTool,
   const Handle(Transfer_FinderProcess)& FP,
@@ -108,8 +106,6 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
     //  Il reste ici et la du code relatif a "en Faceted on combine differemment"
     //  -> reste encore du menage a faire
 
-
-
     TopExp_Explorer anExp;
 
     TopoDSToStep_MakeStepFace MkFace;
@@ -182,7 +178,6 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
         done = Standard_True;
       }
     }
-
     break;
   }
 
@@ -199,7 +194,9 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
     
     if (theTessellatedGeomParam == 1 || (theTessellatedGeomParam == 2 && !MkFace.IsDone())) {
       Message_ProgressScope aPS(theProgress, NULL, 1);
-      MkTessFace.Init(Face, myTool, FP, aPS.Next());
+      // fourth parameter is true in order to create a tessellated_surface_set entity
+      // or put false to create a triangulated_face instead
+      MkTessFace.Init(Face, myTool, FP, Standard_True, aPS.Next());
     }
 
     if (MkFace.IsDone() || MkTessFace.IsDone()) {
@@ -229,10 +226,9 @@ void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
 }
 
 // ============================================================================
-// Method  : TopoDSToStep_Builder::Value
+// Method  : Value
 // Purpose : Returns TopologicalRepresentationItem as the result
 // ============================================================================
-
 const Handle(StepShape_TopologicalRepresentationItem)& 
 TopoDSToStep_Builder::Value() const 
 {
@@ -241,10 +237,9 @@ TopoDSToStep_Builder::Value() const
 }
 
 // ============================================================================
-// Method  : TopoDSToStep_Builder::TessellatedValue
+// Method  : TessellatedValue
 // Purpose : Returns TopologicalRepresentationItem as the optional result
 // ============================================================================
-
 const Handle(StepVisual_TessellatedItem)&
 TopoDSToStep_Builder::TessellatedValue() const
 {
@@ -253,10 +248,9 @@ TopoDSToStep_Builder::TessellatedValue() const
 }
 
 // ============================================================================
-// Method  : TopoDSToStep_Builder::Error
+// Method  : Error
 // Purpose : Returns builder error if the process is not done
 // ============================================================================
-
 TopoDSToStep_BuilderError TopoDSToStep_Builder::Error() const 
 {
   return myError;
index b0bbf78d5e45a52fe055d9989604a99e0e980a37..1987fc52a62114a57d0809997bc758aca5b17820 100644 (file)
@@ -58,7 +58,15 @@ TopoDSToStep_MakeShellBasedSurfaceModel::
   done = Standard_False;
   MoniTool_DataMapOfShapeTransient aMap;
 
-  const Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
+  Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
+  const Standard_Integer aWriteTessSchema = Interface_Static::IVal("write.step.schema");
+  if (aWriteTessSchema != 5)
+  {
+    aWriteTessGeom = 0;
+    Handle(TransferBRep_ShapeMapper) anErrShape =
+      new TransferBRep_ShapeMapper(aFace);
+    FP->AddWarning(anErrShape, " Tessellation can not be exported into not AP242");
+  }
 
   TopoDSToStep_Tool    aTool(aMap, Standard_False);
   TopoDSToStep_Builder StepB(aFace, aTool, FP, aWriteTessGeom, theLocalFactors, theProgress);
@@ -104,7 +112,6 @@ TopoDSToStep_MakeShellBasedSurfaceModel::
 //=============================================================================
 // Create a ShellBasedSurfaceModel of StepShape from a Shell of TopoDS
 //=============================================================================
-
 TopoDSToStep_MakeShellBasedSurfaceModel::
   TopoDSToStep_MakeShellBasedSurfaceModel(const TopoDS_Shell& aShell,
                                           const Handle(Transfer_FinderProcess)& FP,
@@ -118,7 +125,15 @@ TopoDSToStep_MakeShellBasedSurfaceModel::
   Handle(StepShape_ClosedShell)                   aClosedShell;
   MoniTool_DataMapOfShapeTransient                aMap;
 
-  const Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
+  Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
+  const Standard_Integer aWriteTessSchema = Interface_Static::IVal("write.step.schema");
+  if (aWriteTessSchema != 5)
+  {
+    aWriteTessGeom = 0;
+    Handle(TransferBRep_ShapeMapper) anErrShape =
+      new TransferBRep_ShapeMapper(aShell);
+    FP->AddWarning(anErrShape, " Tessellation can not be exported into not AP242");
+  }
 
   TopoDSToStep_Tool    aTool(aMap, Standard_False);
   TopoDSToStep_Builder StepB(aShell, aTool, FP, aWriteTessGeom, theLocalFactors, theProgress);
@@ -178,7 +193,15 @@ TopoDSToStep_MakeShellBasedSurfaceModel::
   TColStd_SequenceOfTransient      S;
   TColStd_SequenceOfTransient      aTessShells;
 
-  const Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
+  Standard_Integer aWriteTessGeom = Interface_Static::IVal("write.step.tessellated");
+  const Standard_Integer aWriteTessSchema = Interface_Static::IVal("write.step.schema");
+  if (aWriteTessSchema != 5)
+  {
+    aWriteTessGeom = 0;
+    Handle(TransferBRep_ShapeMapper) anErrShape =
+      new TransferBRep_ShapeMapper(aShell);
+    FP->AddWarning(anErrShape, " Tessellation can not be exported into not AP242");
+  }
 
   Standard_Integer nbshapes = 0;
   for (It.Initialize(aSolid); It.More(); It.Next())
index 07efb29c47eb200cd0886091fe309b937f4f9ace..8cf4319f16e1c58779e3cee71e1fdddb8231b325 100644 (file)
@@ -19,6 +19,7 @@
 #include <StepShape_TopologicalRepresentationItem.hxx>
 #include <StepVisual_TessellatedShell.hxx>
 #include <StepVisual_TriangulatedFace.hxx>
+#include <StepVisual_TriangulatedSurfaceSet.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopLoc_Location.hxx>
 #include <TopoDS.hxx>
 #include <TransferBRep_ShapeMapper.hxx>
 
 //=============================================================================
-// 
+// Method  : InitTriangulation
+// Purpose : Get parameters from a TriangulatedFace or TriangulatedSurfaceSet 
+// Poly_Triangulation
 //=============================================================================
+static void InitTriangulation(const Handle(Poly_Triangulation)& theMesh,
+                              const Handle(TCollection_HAsciiString)& theName,
+                              Handle(StepVisual_CoordinatesList)& theCoordinates,
+                              Handle(TColgp_HArray1OfXYZ)& thePoints,
+                              Handle(TColStd_HArray2OfReal)& theNormals,
+                              Handle(TColStd_HArray1OfInteger)& theIndices,
+                              Handle(TColStd_HArray2OfInteger)& theTrias)
+{
+  for (Standard_Integer aNodeIndex = 1; aNodeIndex <= theMesh->NbNodes(); ++aNodeIndex)
+  {
+    thePoints->SetValue(aNodeIndex, theMesh->Node(aNodeIndex).XYZ());
+  }
+  theCoordinates->Init(theName, thePoints);
+  if (!theMesh->HasNormals())
+  {
+    Poly::ComputeNormals(theMesh);
+  }
+  for (Standard_Integer aNodeIndex = 1; aNodeIndex <= theMesh->NbNodes(); ++aNodeIndex)
+  {
+    gp_Dir aNorm = theMesh->Normal(aNodeIndex);
+    theNormals->SetValue(aNodeIndex, 1, aNorm.X());
+    theNormals->SetValue(aNodeIndex, 2, aNorm.Y());
+    theNormals->SetValue(aNodeIndex, 3, aNorm.Z());
+  }
+  for (Standard_Integer aNodeIndex = 1; aNodeIndex <= theMesh->NbNodes(); ++aNodeIndex)
+  {
+    theIndices->SetValue(aNodeIndex, aNodeIndex);
+  }
+  for (Standard_Integer aTriangleIndex = 1; aTriangleIndex <= theMesh->NbTriangles(); ++aTriangleIndex)
+  {
+    const Poly_Triangle& aT = theMesh->Triangle(aTriangleIndex);
+    theTrias->SetValue(aTriangleIndex, 1, aT.Value(1));
+    theTrias->SetValue(aTriangleIndex, 2, aT.Value(2));
+    theTrias->SetValue(aTriangleIndex, 3, aT.Value(3));
+  }
+}
 
+//=============================================================================
+// function: TopoDSToStep_MakeTessellatedItem
+// purpose :
+//=============================================================================
 TopoDSToStep_MakeTessellatedItem::TopoDSToStep_MakeTessellatedItem()
   : TopoDSToStep_Root()
 {
 }
 
+//=============================================================================
+// function: TopoDSToStep_MakeTessellatedItem
+// purpose :
+//=============================================================================
 TopoDSToStep_MakeTessellatedItem::
 TopoDSToStep_MakeTessellatedItem(const TopoDS_Face& theFace,
                                  TopoDSToStep_Tool& theTool,
                                  const Handle(Transfer_FinderProcess)& theFP,
+                                 const Standard_Boolean theToPreferSurfaceSet,
                                  const Message_ProgressRange& theProgress)
   : TopoDSToStep_Root()
 {
-  Init(theFace, theTool, theFP, theProgress);
+  Init(theFace, theTool, theFP, theToPreferSurfaceSet, theProgress);
 }
 
 //=============================================================================
-// 
+// function: TopoDSToStep_MakeTessellatedItem
+// purpose :
 //=============================================================================
-
 TopoDSToStep_MakeTessellatedItem::
 TopoDSToStep_MakeTessellatedItem(const TopoDS_Shell& theShell,
                                  TopoDSToStep_Tool& theTool,
@@ -62,83 +110,65 @@ TopoDSToStep_MakeTessellatedItem(const TopoDS_Shell& theShell,
 }
 
 //=============================================================================
-// Create a TriangulatedFace of StepVisual from a Face of TopoDS
+// Method  : Init
+// Purpose : Create a TriangulatedFace or TriangulatedSurfaceSet of StepVisual
+// from a Face of TopoDS
 //=============================================================================
-
 void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Face& theFace,
                                             TopoDSToStep_Tool& theTool,
                                             const Handle(Transfer_FinderProcess)& theFP,
+                                            const Standard_Boolean theToPreferSurfaceSet,
                                             const Message_ProgressRange& theProgress)
 {
   done = Standard_False;
-
   if (theProgress.UserBreak())
     return;
-
   TopLoc_Location aLoc;
   const Handle(Poly_Triangulation)& aMesh = BRep_Tool::Triangulation(theFace, aLoc);
-  if (!aMesh.IsNull()) 
+  if (aMesh.IsNull())
+  {
+    Handle(TransferBRep_ShapeMapper) anErrShape =
+      new TransferBRep_ShapeMapper(theFace);
+    theFP->AddWarning(anErrShape, " Face not mapped to TessellatedItem");
+    return;
+  }
+  Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString("");
+  Handle(StepVisual_CoordinatesList) aCoordinates = new StepVisual_CoordinatesList();
+  Handle(TColgp_HArray1OfXYZ) aPoints = new TColgp_HArray1OfXYZ(1, aMesh->NbNodes());
+  Handle(TColStd_HArray2OfReal) aNormals = new TColStd_HArray2OfReal(1, aMesh->NbNodes(), 1, 3);
+  Handle(TColStd_HArray1OfInteger) anIndices = new TColStd_HArray1OfInteger(1, aMesh->NbNodes());
+  Handle(TColStd_HArray2OfInteger) aTrias = new TColStd_HArray2OfInteger(1, aMesh->NbTriangles(), 1, 3);
+  InitTriangulation(aMesh, aName, aCoordinates, aPoints, aNormals, anIndices, aTrias);
+
+  const Standard_Boolean aHasGeomLink = theTool.IsBound(theFace);
+  StepVisual_FaceOrSurface aGeomLink;
+  if (aHasGeomLink)
   {
+    Handle(StepShape_TopologicalRepresentationItem) aTopoItem = theTool.Find(theFace);
+    aGeomLink.SetValue(aTopoItem);
     Handle(StepVisual_TriangulatedFace) aTriaFace = new StepVisual_TriangulatedFace();
-    Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString("");
-    Handle(StepVisual_CoordinatesList) aCoordinates = new StepVisual_CoordinatesList();
-    Handle(TColgp_HArray1OfXYZ) aPoints = new TColgp_HArray1OfXYZ(1, aMesh->NbNodes());
-    for (Standard_Integer i = 1; i <= aMesh->NbNodes(); ++i) 
-    {
-      aPoints->SetValue(i, aMesh->Node(i).XYZ());
-    }
-    aCoordinates->Init(aName, aPoints);
-    Handle(TColStd_HArray2OfReal) aNormals = new TColStd_HArray2OfReal(1, aMesh->NbNodes(), 1, 3);
-    if (!aMesh->HasNormals()) 
-    {
-      Poly::ComputeNormals(aMesh);
-    }
-    for (Standard_Integer i = 1; i <= aMesh->NbNodes(); ++i)
-    {
-      gp_Dir aNorm = aMesh->Normal(i);
-      aNormals->SetValue(i, 1, aNorm.X());
-      aNormals->SetValue(i, 2, aNorm.Y());
-      aNormals->SetValue(i, 3, aNorm.Z());
-    }
-    const Standard_Boolean aHasGeomLink = theTool.IsBound(theFace);
-    StepVisual_FaceOrSurface aGeomLink;
-    if (aHasGeomLink) 
-    {
-      Handle(StepShape_TopologicalRepresentationItem) aTopoItem = theTool.Find(theFace);
-      aGeomLink.SetValue(aTopoItem);
-    }
-    Handle(TColStd_HArray1OfInteger) anIndices = new TColStd_HArray1OfInteger(1, aMesh->NbNodes());
-    for (Standard_Integer i = 1; i <= aMesh->NbNodes(); ++i) 
-    {
-      anIndices->SetValue(i, i);
-    }
-    Handle(TColStd_HArray2OfInteger) aTrias = new TColStd_HArray2OfInteger(1, aMesh->NbTriangles(), 1, 3);
-    for (Standard_Integer i = 1; i <= aMesh->NbTriangles(); ++i) 
-    {
-      const Poly_Triangle& aT = aMesh->Triangle(i);
-      aTrias->SetValue(i, 1, aT.Value(1));
-      aTrias->SetValue(i, 2, aT.Value(2));
-      aTrias->SetValue(i, 3, aT.Value(3));
-    }
     aTriaFace->Init(aName, aCoordinates, aMesh->NbNodes(), aNormals, aHasGeomLink, aGeomLink, anIndices, aTrias);
     theTessellatedItem = aTriaFace;
-
-    done = Standard_True;
   }
-  else 
+  else if (theToPreferSurfaceSet)
   {
-    done = Standard_False;
-    Handle(TransferBRep_ShapeMapper) anErrShape =
-      new TransferBRep_ShapeMapper(theFace);
-    theFP->AddWarning(anErrShape, " Face not mapped to TessellatedItem");
+    Handle(StepVisual_TriangulatedSurfaceSet) aTriaSurfaceSet = new StepVisual_TriangulatedSurfaceSet();
+    aTriaSurfaceSet->Init(aName, aCoordinates, aMesh->NbNodes(), aNormals, anIndices, aTrias);
+    theTessellatedItem = aTriaSurfaceSet;
   }
-
+  else
+  {
+    Handle(StepVisual_TriangulatedFace) aTriaFace = new StepVisual_TriangulatedFace();
+    aTriaFace->Init(aName, aCoordinates, aMesh->NbNodes(), aNormals, aHasGeomLink, aGeomLink, anIndices, aTrias);
+    theTessellatedItem = aTriaFace;
+  }
+  done = Standard_True;
 }
 
 //=============================================================================
-// Create a TesselatedShell of StepVisual from a Shell of TopoDS
+// Method  : Init
+// Purpose : Create a TesselatedShell of StepVisual from a Shell of TopoDS
 //=============================================================================
-
 void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Shell& theShell,
                                             TopoDSToStep_Tool& theTool,
                                             const Handle(Transfer_FinderProcess)& theFP,
@@ -160,7 +190,7 @@ void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Shell& theShell,
   for (anExp.Init(theShell, TopAbs_FACE); anExp.More() && aPS.More(); anExp.Next(), aPS.Next())
   {
     const TopoDS_Face aFace = TopoDS::Face(anExp.Current());
-    TopoDSToStep_MakeTessellatedItem aMakeFace(aFace, theTool, theFP, aPS.Next());
+    TopoDSToStep_MakeTessellatedItem aMakeFace(aFace, theTool, theFP, Standard_False, aPS.Next());
     if (aMakeFace.IsDone()) 
     {
       aTessFaces.Append(Handle(StepVisual_TessellatedStructuredItem)::DownCast(aMakeFace.Value()));
@@ -177,9 +207,9 @@ void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Shell& theShell,
 
   Handle(StepVisual_HArray1OfTessellatedStructuredItem) anItems
     = new StepVisual_HArray1OfTessellatedStructuredItem(1, aTessFaces.Size());
-  for (Standard_Integer i = aTessFaces.Lower(); i <= aTessFaces.Upper(); ++i)
+  for (Standard_Integer anIndx = aTessFaces.Lower(); anIndx <= aTessFaces.Upper(); ++anIndx)
   {
-    anItems->SetValue(i, aTessFaces.Value(i));
+    anItems->SetValue(anIndx, aTessFaces.Value(anIndx));
   }
 
   Handle(StepShape_ConnectedFaceSet) aFaceSet;
@@ -198,10 +228,9 @@ void TopoDSToStep_MakeTessellatedItem::Init(const TopoDS_Shell& theShell,
 }
 
 // ============================================================================
-// Method  : TopoDSToStep_MakeTessellatedItem::Value
+// Method  : Value
 // Purpose : Returns TessellatedItem as the result
 // ============================================================================
-
 const Handle(StepVisual_TessellatedItem) &
 TopoDSToStep_MakeTessellatedItem::Value() const
 {
index 41a2cb8b2d3762f3070660489828715a48ad0c2d..8656cdf5589451d616346e22fea404bc8595187f 100644 (file)
@@ -40,6 +40,7 @@ public:
   Standard_EXPORT TopoDSToStep_MakeTessellatedItem(const TopoDS_Face& theFace,
                                                    TopoDSToStep_Tool& theTool,
                                                    const Handle(Transfer_FinderProcess)& theFP,
+                                                   const Standard_Boolean theToPreferSurfaceSet,
                                                    const Message_ProgressRange& theProgress = Message_ProgressRange());
   
   Standard_EXPORT TopoDSToStep_MakeTessellatedItem(const TopoDS_Shell& theShell,
@@ -50,6 +51,7 @@ public:
   Standard_EXPORT void Init(const TopoDS_Face& theFace,
                             TopoDSToStep_Tool& theTool,
                             const Handle(Transfer_FinderProcess)& theFP,
+                            const Standard_Boolean theToPreferSurfaceSet,
                             const Message_ProgressRange& theProgress = Message_ProgressRange());
   
   Standard_EXPORT void Init(const TopoDS_Shell& theShell,
@@ -59,28 +61,10 @@ public:
   
   Standard_EXPORT const Handle(StepVisual_TessellatedItem)& Value() const;
 
-
-
-
-protected:
-
-
-
-
-
 private:
 
-
-
   Handle(StepVisual_TessellatedItem) theTessellatedItem;
 
-
 };
 
-
-
-
-
-
-
 #endif // _TopoDSToStep_MakeTessellatedItem_HeaderFile
index 07d984e683e750f0daced1cb0e275d747a9179c2..3e8a24792d7ba6aceb74c73d650361a78a05c46e 100644 (file)
@@ -1,5 +1,7 @@
 pload XDE OCAF MODELING
 
 # enable reading/writing tessellated STEP geometry
+param write.step.schema AP242DIS
 param read.step.tessellated On
 param write.step.tessellated On
+newmodel
index fd5f18a17dbfe9c14a469fe674e29204c37849a4..c3cd6e0c41f8cb78cff3902dedce34de5e53aa8f 100644 (file)
@@ -16,5 +16,6 @@ vdump ${imagedir}/${casename}.png
 Close D -silent
 unset S
 
+param write.step.schema AP214CD
 param read.step.tessellated Off
 param write.step.tessellated Off
diff --git a/tests/de_mesh/step_write/D1 b/tests/de_mesh/step_write/D1
new file mode 100644 (file)
index 0000000..095589c
--- /dev/null
@@ -0,0 +1,8 @@
+# load from mesh (XBF) format
+
+XOpen [locate_data_file "bug32666.xbf"] D1
+XGetOneShape S D1
+
+set nb_faces     3
+set nb_nodes     428
+set nb_triangles 372
diff --git a/tests/de_mesh/step_write/D2 b/tests/de_mesh/step_write/D2
new file mode 100644 (file)
index 0000000..102f062
--- /dev/null
@@ -0,0 +1,8 @@
+# load from mesh (STEP) format 
+ReadStep D1 [locate_data_file "bug30024_tessell.stp"] 
+XGetOneShape S D1
+newmodel
+
+set nb_faces     131
+set nb_nodes     2216
+set nb_triangles 2118
index 07d984e683e750f0daced1cb0e275d747a9179c2..3e8a24792d7ba6aceb74c73d650361a78a05c46e 100644 (file)
@@ -1,5 +1,7 @@
 pload XDE OCAF MODELING
 
 # enable reading/writing tessellated STEP geometry
+param write.step.schema AP242DIS
 param read.step.tessellated On
 param write.step.tessellated On
+newmodel
index 3a5f84ddcf69e5f89d234e896f631ef80f266e53..d57a37aa14beac84ce653833f4b086abde80efbe 100644 (file)
@@ -1,4 +1,3 @@
-
 # save the initial shape to STEP
 stepwrite a S "${imagedir}/${casename}.stp"
 
@@ -29,5 +28,6 @@ unset S
 unset S1
 
 # restore reading/writing tessellated STEP geometry default parameters
+param write.step.schema AP214CD
 param read.step.tessellated On
 param write.step.tessellated OnNoBRep