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
#include <StepVisual_ComplexTriangulatedSurfaceSet.hxx>
#include <StepVisual_CubicBezierTessellatedEdge.hxx>
#include <StepVisual_CubicBezierTriangulatedFace.hxx>
+#include <StepVisual_TriangulatedSurfaceSet.hxx>
#include <RWStepVisual_RWTessellatedConnectingEdge.hxx>
#include <RWStepVisual_RWTessellatedEdge.hxx>
#include <RWStepVisual_RWComplexTriangulatedSurfaceSet.hxx>
#include <RWStepVisual_RWCubicBezierTessellatedEdge.hxx>
#include <RWStepVisual_RWCubicBezierTriangulatedFace.hxx>
+#include <RWStepVisual_RWTriangulatedSurfaceSet.hxx>
static Standard_Integer catsh,catdr,catstr,catdsc,cataux;
aTool.Share(anEnt, iter);
}
break;
+ case 819:
+ {
+ DeclareAndCast(StepVisual_TriangulatedSurfaceSet, anEnt, ent);
+ RWStepVisual_RWTriangulatedSurfaceSet aTool;
+ aTool.Share(anEnt, iter);
+ }
+ break;
default : break;
}
}
case 818:
ent = new StepVisual_CubicBezierTriangulatedFace;
break;
+ case 819:
+ ent = new StepVisual_TriangulatedSurfaceSet;
+ break;
default:
return Standard_False;
#include <StepVisual_ComplexTriangulatedSurfaceSet.hxx>
#include <StepVisual_CubicBezierTessellatedEdge.hxx>
#include <StepVisual_CubicBezierTriangulatedFace.hxx>
+#include <StepVisual_TriangulatedSurfaceSet.hxx>
#include <RWStepVisual_RWTessellatedConnectingEdge.hxx>
#include <RWStepVisual_RWTessellatedEdge.hxx>
#include <RWStepVisual_RWComplexTriangulatedSurfaceSet.hxx>
#include <RWStepVisual_RWCubicBezierTessellatedEdge.hxx>
#include <RWStepVisual_RWCubicBezierTriangulatedFace.hxx>
+#include <RWStepVisual_RWTriangulatedSurfaceSet.hxx>
#include <RWStepBasic_RWAddress.hxx>
#include <RWStepShape_RWAdvancedBrepShapeRepresentation.hxx>
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 --
typenums.Bind(Reco_ComplexTriangulatedSurfaceSet, 816);
typenums.Bind(Reco_CubicBezierTessellatedEdge, 817);
typenums.Bind(Reco_CubicBezierTriangulatedFace, 818);
+ typenums.Bind(Reco_TriangulatedSurfaceSet, 819);
// SHORT NAMES
case 816: return Reco_ComplexTriangulatedSurfaceSet;
case 817: return Reco_CubicBezierTessellatedEdge;
case 818: return Reco_CubicBezierTriangulatedFace;
+ case 819: return Reco_TriangulatedSurfaceSet;
default : return PasReco;
}
}
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");
}
aTool.WriteStep(SW, anEnt);
}
break;
+ case 819:
+ {
+ DeclareAndCast(StepVisual_TriangulatedSurfaceSet, anEnt, ent);
+ RWStepVisual_RWTriangulatedSurfaceSet aTool;
+ aTool.WriteStep(SW, anEnt);
+ }
+ break;
default:
return;
}
RWStepVisual_RWTessellatedWire.hxx
RWStepVisual_RWTriangulatedFace.cxx
RWStepVisual_RWTriangulatedFace.hxx
+RWStepVisual_RWTriangulatedSurfaceSet.cxx
+RWStepVisual_RWTriangulatedSurfaceSet.hxx
--- /dev/null
+// 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());
+}
--- /dev/null
+// 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_
#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>
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;
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.");
#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
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);
}
#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>
}
// ============================================================================
-// Method : StepToTopoDS_Builder::StepToTopoDS_Builder
+// Method : StepToTopoDS_Builder
// Purpose : Empty constructor
// ============================================================================
-
StepToTopoDS_Builder::StepToTopoDS_Builder()
: myError(StepToTopoDS_BuilderOther)
{
// 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;
}
// ============================================================================
// ***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,
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,
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,
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;
}
// ============================================================================
class StepVisual_TessellatedFace;
class StepVisual_TessellatedShell;
class StepVisual_TessellatedSolid;
+class StepVisual_TessellatedSurfaceSet;
class Transfer_ActorOfTransientProcess;
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());
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;
#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()
}
// ============================================================================
-// 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,
}
// ============================================================================
-// 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,
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;
// 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,
// ----------------------------------------------
// 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
// ----------------------------------
// Iterate on each FaceBounds (Wires)
// ----------------------------------
-
Handle(StepShape_FaceBound) FaceBound;
Handle(StepShape_Loop) Loop;
// ----------------------
// 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);
// -----------------------
// The Loop is an EdgeLoop
// -----------------------
-
else if (Loop->IsKind(STANDARD_TYPE(StepShape_EdgeLoop))) {
//:S4136 if (STF.Closed()) {
//:S4136 Handle(StepShape_EdgeLoop) EL =
// -----------------------------
// The Wire is added to the Face
// -----------------------------
-
B.Add(F, W);
}
else {
// 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,
}
// ============================================================================
-// 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");
// Method : Error
// Purpose : Return the TranslateFace error
// ============================================================================
-
StepToTopoDS_TranslateFaceError StepToTopoDS_TranslateFace::Error() const
{
return myError;
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
{
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,
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;
};
-
-
-
-
-
#endif // _StepToTopoDS_TranslateFace_HeaderFile
StepVisual_TessellatedWire.hxx
StepVisual_TriangulatedFace.cxx
StepVisual_TriangulatedFace.hxx
+StepVisual_TriangulatedSurfaceSet.cxx
+StepVisual_TriangulatedSurfaceSet.hxx
//purpose :
//=======================================================================
-StepVisual_TriangulatedFace::StepVisual_TriangulatedFace ()
+StepVisual_TriangulatedFace::StepVisual_TriangulatedFace()
+ : StepVisual_TessellatedFace()
{
}
public :
- //! default constructor
+ //! Default constructor
Standard_EXPORT StepVisual_TriangulatedFace();
//! Initialize all fields (own and inherited)
--- /dev/null
+// 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();
+}
--- /dev/null
+// 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_
#include <Transfer_FinderProcess.hxx>
// ============================================================================
-// Method : TopoDSToStep_Builder::TopoDSToStep_Builder
+// Method : TopoDSToStep_Builder
// Purpose :
// ============================================================================
TopoDSToStep_Builder::TopoDSToStep_Builder()
}
// ============================================================================
-// Method : TopoDSToStep_Builder::TopoDSToStep_Builder
+// Method : TopoDSToStep_Builder
// Purpose :
// ============================================================================
-
TopoDSToStep_Builder::TopoDSToStep_Builder
(const TopoDS_Shape& aShape,
TopoDSToStep_Tool& aTool,
}
// ============================================================================
-// Method : TopoDSToStep_Builder::Init
+// Method : Init
// Purpose :
// ============================================================================
-
void TopoDSToStep_Builder::Init(const TopoDS_Shape& aShape,
TopoDSToStep_Tool& myTool,
const Handle(Transfer_FinderProcess)& FP,
// 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;
done = Standard_True;
}
}
-
break;
}
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()) {
}
// ============================================================================
-// Method : TopoDSToStep_Builder::Value
+// Method : Value
// Purpose : Returns TopologicalRepresentationItem as the result
// ============================================================================
-
const Handle(StepShape_TopologicalRepresentationItem)&
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
{
}
// ============================================================================
-// Method : TopoDSToStep_Builder::Error
+// Method : Error
// Purpose : Returns builder error if the process is not done
// ============================================================================
-
TopoDSToStep_BuilderError TopoDSToStep_Builder::Error() const
{
return myError;
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);
//=============================================================================
// Create a ShellBasedSurfaceModel of StepShape from a Shell of TopoDS
//=============================================================================
-
TopoDSToStep_MakeShellBasedSurfaceModel::
TopoDSToStep_MakeShellBasedSurfaceModel(const TopoDS_Shell& aShell,
const Handle(Transfer_FinderProcess)& FP,
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);
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())
#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,
}
//=============================================================================
-// 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,
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()));
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;
}
// ============================================================================
-// Method : TopoDSToStep_MakeTessellatedItem::Value
+// Method : Value
// Purpose : Returns TessellatedItem as the result
// ============================================================================
-
const Handle(StepVisual_TessellatedItem) &
TopoDSToStep_MakeTessellatedItem::Value() const
{
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,
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,
Standard_EXPORT const Handle(StepVisual_TessellatedItem)& Value() const;
-
-
-
-protected:
-
-
-
-
-
private:
-
-
Handle(StepVisual_TessellatedItem) theTessellatedItem;
-
};
-
-
-
-
-
-
#endif // _TopoDSToStep_MakeTessellatedItem_HeaderFile
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
Close D -silent
unset S
+param write.step.schema AP214CD
param read.step.tessellated Off
param write.step.tessellated Off
--- /dev/null
+# 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
--- /dev/null
+# 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
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
-
# save the initial shape to STEP
stepwrite a S "${imagedir}/${casename}.stp"
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