1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-13 14:27:08 +03:00

Compare commits

..

1 Commits

Author SHA1 Message Date
oan
8c3e6633b8 0031586: BRepMesh hangs up
Use NCollection_UBTree to detect intersections between newly added links and contour of the polygon;
Perform check of the solutions for link insertion after all possible solutions are found and sorted according to their priority.
2022-12-22 15:51:09 +03:00
130 changed files with 5932 additions and 6922 deletions

View File

@@ -1,51 +0,0 @@
// Copyright (c) 2023 OPEN CASCADE SAS
//
// 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 <AIS_AnimationAxisRotation.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject)
//=============================================================================
//function : Constructor
//purpose :
//=============================================================================
AIS_AnimationAxisRotation::AIS_AnimationAxisRotation (const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject,
const gp_Ax1& theAxis,
const Standard_Real theAngleStart,
const Standard_Real theAngleEnd)
: AIS_BaseAnimationObject (theAnimationName, theContext, theObject),
myRotAxis (theAxis),
myAngleStart (theAngleStart),
myAngleEnd (theAngleEnd)
{
//
}
//=============================================================================
//function : update
//purpose :
//=============================================================================
void AIS_AnimationAxisRotation::update (const AIS_AnimationProgress& theProgress)
{
if (myObject.IsNull())
{
return;
}
gp_Trsf aTrsf;
Standard_Real aCurrentAngle = (1.0 - theProgress.LocalNormalized) * myAngleStart + theProgress.LocalNormalized * myAngleEnd;
aTrsf.SetRotation (myRotAxis, aCurrentAngle);
updateTrsf (aTrsf);
}

View File

@@ -1,53 +0,0 @@
// Copyright (c) 2023 OPEN CASCADE SAS
//
// 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 _AIS_AnimationAxisRotation_HeaderFile
#define _AIS_AnimationAxisRotation_HeaderFile
#include <AIS_BaseAnimationObject.hxx>
#include <gp_TrsfNLerp.hxx>
//! Animation defining object transformation.
class AIS_AnimationAxisRotation : public AIS_BaseAnimationObject
{
DEFINE_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject)
public:
//! Constructor with initialization.
//! @param[in] theAnimationName animation identifier
//! @param[in] theContext interactive context where object have been displayed
//! @param[in] theObject object to apply rotation
//! @param[in] theAxis rotation axis
//! @param[in] theAngleStart rotation angle at the start of animation
//! @param[in] theAngleEnd rotation angle at the end of animation
Standard_EXPORT AIS_AnimationAxisRotation (const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject,
const gp_Ax1& theAxis,
const Standard_Real theAngleStart,
const Standard_Real theAngleEnd);
protected:
//! Update the progress.
Standard_EXPORT virtual void update (const AIS_AnimationProgress& theProgress) Standard_OVERRIDE;
private:
gp_Ax1 myRotAxis; //!< rotation axis
Standard_Real myAngleStart; //!< start angle for rotation
Standard_Real myAngleEnd; //!< end angle for rotation
};
#endif // _AIS_AnimationAxisRotation_HeaderFile

View File

@@ -14,7 +14,10 @@
#include <AIS_AnimationObject.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_BaseAnimationObject)
#include <AIS_InteractiveContext.hxx>
#include <V3d_View.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_Animation)
//=============================================================================
//function : Constructor
@@ -25,7 +28,9 @@ AIS_AnimationObject::AIS_AnimationObject (const TCollection_AsciiString& theAnim
const Handle(AIS_InteractiveObject)& theObject,
const gp_Trsf& theTrsfStart,
const gp_Trsf& theTrsfEnd)
: AIS_BaseAnimationObject (theAnimationName, theContext, theObject),
: AIS_Animation (theAnimationName),
myContext (theContext),
myObject (theObject),
myTrsfLerp (theTrsfStart, theTrsfEnd)
{
//
@@ -44,5 +49,52 @@ void AIS_AnimationObject::update (const AIS_AnimationProgress& theProgress)
gp_Trsf aTrsf;
myTrsfLerp.Interpolate (theProgress.LocalNormalized, aTrsf);
updateTrsf (aTrsf);
if (!myContext.IsNull())
{
myContext->SetLocation (myObject, aTrsf);
invalidateViewer();
}
else
{
myObject->SetLocalTransformation (aTrsf);
}
}
//=============================================================================
//function : invalidateViewer
//purpose :
//=============================================================================
void AIS_AnimationObject::invalidateViewer()
{
if (myContext.IsNull())
{
return;
}
const Standard_Boolean isImmediate = myContext->CurrentViewer()->ZLayerSettings (myObject->ZLayer()).IsImmediate();
if (!isImmediate)
{
myContext->CurrentViewer()->Invalidate();
return;
}
// Invalidate immediate view only if it is going out of z-fit range.
// This might be sub-optimal performing this for each animated objects in case of many animated objects.
for (V3d_ListOfView::Iterator aDefViewIter = myContext->CurrentViewer()->DefinedViewIterator();
aDefViewIter.More(); aDefViewIter.Next())
{
const Handle(V3d_View)& aView = aDefViewIter.Value();
const Bnd_Box aMinMaxBox = aView->View()->MinMaxValues (Standard_False);
const Bnd_Box aGraphicBox = aView->View()->MinMaxValues (Standard_True);
Standard_Real aZNear = 0.0;
Standard_Real aZFar = 0.0;
if (aView->Camera()->ZFitAll (aDefViewIter.Value()->AutoZFitScaleFactor(), aMinMaxBox, aGraphicBox, aZNear, aZFar))
{
if (aZNear < aView->Camera()->ZNear()
|| aZFar > aView->Camera()->ZFar())
{
aDefViewIter.Value()->Invalidate();
}
}
}
}

View File

@@ -15,23 +15,24 @@
#ifndef _AIS_AnimationObject_HeaderFile
#define _AIS_AnimationObject_HeaderFile
#include <AIS_BaseAnimationObject.hxx>
#include <AIS_Animation.hxx>
#include <AIS_InteractiveContext.hxx>
#include <gp_TrsfNLerp.hxx>
//! Animation defining object transformation.
class AIS_AnimationObject : public AIS_BaseAnimationObject
class AIS_AnimationObject : public AIS_Animation
{
DEFINE_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_BaseAnimationObject)
DEFINE_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_Animation)
public:
//! Constructor with initialization.
//! Note that start/end transformations specify exactly local transformation of the object,
//! not the transformation to be applied to existing local transformation.
//! @param[in] theAnimationName animation identifier
//! @param[in] theContext interactive context where object have been displayed
//! @param[in] theObject object to apply local transformation
//! @param[in] theTrsfStart local transformation at the start of animation (e.g. theObject->LocalTransformation())
//! @param[in] theTrsfEnd local transformation at the end of animation
//! @param theAnimationName animation identifier
//! @param theContext interactive context where object have been displayed
//! @param theObject object to apply local transformation
//! @param theTrsfStart local transformation at the start of animation (e.g. theObject->LocalTransformation())
//! @param theTrsfEnd local transformation at the end of animation
Standard_EXPORT AIS_AnimationObject (const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject,
@@ -43,10 +44,17 @@ protected:
//! Update the progress.
Standard_EXPORT virtual void update (const AIS_AnimationProgress& theProgress) Standard_OVERRIDE;
private:
//! Invalidate the viewer for proper update.
Standard_EXPORT void invalidateViewer();
gp_TrsfNLerp myTrsfLerp; //!< interpolation tool
protected:
Handle(AIS_InteractiveContext) myContext; //!< context where object is displayed
Handle(AIS_InteractiveObject) myObject; //!< presentation object to set location
gp_TrsfNLerp myTrsfLerp; //!< interpolation tool
};
DEFINE_STANDARD_HANDLE(AIS_AnimationObject, AIS_Animation)
#endif // _AIS_AnimationObject_HeaderFile

View File

@@ -1,88 +0,0 @@
// Copyright (c) 2023 OPEN CASCADE SAS
//
// 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 <AIS_BaseAnimationObject.hxx>
#include <V3d_View.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_BaseAnimationObject, AIS_Animation)
//=============================================================================
//function : Constructor
//purpose :
//=============================================================================
AIS_BaseAnimationObject::AIS_BaseAnimationObject (const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject)
: AIS_Animation (theAnimationName),
myContext (theContext),
myObject (theObject)
{
//
}
//=============================================================================
//function : updateTrsf
//purpose :
//=============================================================================
void AIS_BaseAnimationObject::updateTrsf (const gp_Trsf& theTrsf)
{
if (!myContext.IsNull())
{
myContext->SetLocation (myObject, theTrsf);
invalidateViewer();
}
else
{
myObject->SetLocalTransformation (theTrsf);
}
}
//=============================================================================
//function : invalidateViewer
//purpose :
//=============================================================================
void AIS_BaseAnimationObject::invalidateViewer()
{
if (myContext.IsNull())
{
return;
}
const Standard_Boolean isImmediate = myContext->CurrentViewer()->ZLayerSettings (myObject->ZLayer()).IsImmediate();
if (!isImmediate)
{
myContext->CurrentViewer()->Invalidate();
return;
}
// Invalidate immediate view only if it is going out of z-fit range.
// This might be sub-optimal performing this for each animated objects in case of many animated objects.
for (V3d_ListOfView::Iterator aDefViewIter = myContext->CurrentViewer()->DefinedViewIterator();
aDefViewIter.More(); aDefViewIter.Next())
{
const Handle(V3d_View)& aView = aDefViewIter.Value();
const Bnd_Box aMinMaxBox = aView->View()->MinMaxValues (Standard_False);
const Bnd_Box aGraphicBox = aView->View()->MinMaxValues (Standard_True);
Standard_Real aZNear = 0.0;
Standard_Real aZFar = 0.0;
if (aView->Camera()->ZFitAll (aDefViewIter.Value()->AutoZFitScaleFactor(), aMinMaxBox, aGraphicBox, aZNear, aZFar))
{
if (aZNear < aView->Camera()->ZNear()
|| aZFar > aView->Camera()->ZFar())
{
aDefViewIter.Value()->Invalidate();
}
}
}
}

View File

@@ -1,49 +0,0 @@
// Copyright (c) 2023 OPEN CASCADE SAS
//
// 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 _AIS_BaseAnimationObject_HeaderFile
#define _AIS_BaseAnimationObject_HeaderFile
#include <AIS_Animation.hxx>
#include <AIS_InteractiveContext.hxx>
//! Animation defining object transformation.
class AIS_BaseAnimationObject : public AIS_Animation
{
DEFINE_STANDARD_RTTIEXT(AIS_BaseAnimationObject, AIS_Animation)
protected:
//! Constructor with initialization.
//! @param[in] theAnimationName animation identifier
//! @param[in] theContext interactive context where object have been displayed
//! @param[in] theObject object to apply local transformation
Standard_EXPORT AIS_BaseAnimationObject (const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject);
//! Update the transformation.
Standard_EXPORT void updateTrsf (const gp_Trsf& theTrsf);
private:
//! Invalidate the viewer for proper update.
Standard_EXPORT void invalidateViewer();
protected:
Handle(AIS_InteractiveContext) myContext; //!< context where object is displayed
Handle(AIS_InteractiveObject) myObject; //!< presentation object to set location
};
#endif // _AIS_BaseAnimationObject_HeaderFile

View File

@@ -1116,23 +1116,18 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
const Standard_Integer theMode)
{
//Check mode
const AIS_ManipulatorMode aMode = (AIS_ManipulatorMode) theMode;
AIS_ManipulatorMode aMode = (AIS_ManipulatorMode) theMode;
if (aMode == AIS_MM_None)
{
return;
}
Handle(SelectMgr_EntityOwner) anOwner;
// Sensitivity calculation for manipulator parts allows to avoid
// overlapping of sensitive areas when size of manipulator is small.
// Sensitivity is calculated relative to the default size of the manipulator (100.0f).
const Standard_ShortReal aSensitivityCoef = myAxes[0].Size() / 100.0f;
const Standard_Integer aHighSensitivity = Max (Min (RealToInt (aSensitivityCoef * 15), 15), 3); // clamp sensitivity within range [3, 15]
const Standard_Integer aLowSensitivity = Max (Min (RealToInt (aSensitivityCoef * 10), 10), 2); // clamp sensitivity within range [2, 10]
switch (aMode)
if (aMode == AIS_MM_None)
{
case AIS_MM_Translation:
anOwner = new SelectMgr_EntityOwner (this, 5);
}
if (aMode == AIS_MM_Translation || aMode == AIS_MM_None)
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
@@ -1141,21 +1136,23 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
continue;
}
const Axis& anAxis = myAxes[anIt];
anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_Translation, 9);
if (aMode != AIS_MM_None)
{
anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Translation, 9);
}
// define sensitivity by line
Handle(Select3D_SensitiveSegment) aLine = new Select3D_SensitiveSegment(anOwner, gp::Origin(), anAxis.TranslatorTipPosition());
aLine->SetSensitivityFactor (aHighSensitivity);
Handle(Select3D_SensitiveSegment) aLine = new Select3D_SensitiveSegment (anOwner, gp::Origin(), anAxis.TranslatorTipPosition());
aLine->SetSensitivityFactor (15);
theSelection->Add (aLine);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitivePrimitiveArray) aTri = new Select3D_SensitivePrimitiveArray(anOwner);
Handle(Select3D_SensitivePrimitiveArray) aTri = new Select3D_SensitivePrimitiveArray (anOwner);
aTri->InitTriangulation (anAxis.TriangleArray()->Attributes(), anAxis.TriangleArray()->Indices(), TopLoc_Location());
theSelection->Add (aTri);
}
break;
}
case AIS_MM_Rotation:
if (aMode == AIS_MM_Rotation || aMode == AIS_MM_None)
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
@@ -1164,20 +1161,22 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
continue;
}
const Axis& anAxis = myAxes[anIt];
anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_Rotation, 9);
if (aMode != AIS_MM_None)
{
anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Rotation, 9);
}
// define sensitivity by circle
const gp_Circ aGeomCircle (gp_Ax2(gp::Origin(), anAxis.ReferenceAxis().Direction()), anAxis.RotatorDiskRadius());
Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle(anOwner, aGeomCircle);
aCircle->SetSensitivityFactor (aLowSensitivity);
theSelection->Add(aCircle);
const gp_Circ aGeomCircle (gp_Ax2 (gp::Origin(), anAxis.ReferenceAxis().Direction()), anAxis.RotatorDiskRadius());
Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle (anOwner, aGeomCircle);
aCircle->SetSensitivityFactor (15);
theSelection->Add (aCircle);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitiveTriangulation) aTri = new ManipSensTriangulation(anOwner, myAxes[anIt].RotatorDisk().Triangulation(), anAxis.ReferenceAxis().Direction());
Handle(Select3D_SensitiveTriangulation) aTri = new ManipSensTriangulation (anOwner, myAxes[anIt].RotatorDisk().Triangulation(), anAxis.ReferenceAxis().Direction());
theSelection->Add (aTri);
}
break;
}
case AIS_MM_Scaling:
if (aMode == AIS_MM_Scaling || aMode == AIS_MM_None)
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
@@ -1185,19 +1184,21 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
{
continue;
}
anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_Scaling, 9);
if (aMode != AIS_MM_None)
{
anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Scaling, 9);
}
// define sensitivity by point
Handle(Select3D_SensitivePoint) aPnt = new Select3D_SensitivePoint(anOwner, myAxes[anIt].ScalerCubePosition());
aPnt->SetSensitivityFactor (aHighSensitivity);
Handle(Select3D_SensitivePoint) aPnt = new Select3D_SensitivePoint (anOwner, myAxes[anIt].ScalerCubePosition());
aPnt->SetSensitivityFactor (15);
theSelection->Add (aPnt);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation(anOwner, myAxes[anIt].ScalerCube().Triangulation(), TopLoc_Location(), Standard_True);
Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].ScalerCube().Triangulation(), TopLoc_Location(), Standard_True);
theSelection->Add (aTri);
}
break;
}
case AIS_MM_TranslationPlane:
if (aMode == AIS_MM_TranslationPlane || aMode == AIS_MM_None)
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
@@ -1205,33 +1206,28 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
{
continue;
}
anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_TranslationPlane, 9);
if (aMode != AIS_MM_None)
{
anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_TranslationPlane, 9);
}
// define sensitivity by two crossed lines
Standard_Real aSensitivityOffset = ZoomPersistence() ? aHighSensitivity * (0.5 + M_SQRT2) : 0.0;
gp_Pnt aP1 = myAxes[((anIt + 1) % 3)].TranslatorTipPosition().Translated (myAxes[((anIt + 2) % 3)].ReferenceAxis().Direction().XYZ() * aSensitivityOffset);
gp_Pnt aP2 = myAxes[((anIt + 2) % 3)].TranslatorTipPosition().Translated (myAxes[((anIt + 1) % 3)].ReferenceAxis().Direction().XYZ() * aSensitivityOffset);
gp_Pnt aP1, aP2;
aP1 = myAxes[((anIt + 1) % 3)].TranslatorTipPosition();
aP2 = myAxes[((anIt + 2) % 3)].TranslatorTipPosition();
gp_XYZ aMidP = (aP1.XYZ() + aP2.XYZ()) / 2.0;
gp_XYZ anOrig = aMidP.Normalized().Multiplied (aSensitivityOffset);
Handle(Select3D_SensitiveSegment) aLine1 = new Select3D_SensitiveSegment(anOwner, aP1, aP2);
aLine1->SetSensitivityFactor(aLowSensitivity);
theSelection->Add (aLine1);
Handle(Select3D_SensitiveSegment) aLine2 = new Select3D_SensitiveSegment(anOwner, anOrig, aMidP);
aLine2->SetSensitivityFactor (aLowSensitivity);
theSelection->Add (aLine2);
aLine1->SetSensitivityFactor(10);
theSelection->Add(aLine1);
Handle(Select3D_SensitiveSegment) aLine2 = new Select3D_SensitiveSegment(anOwner, gp::Origin(), aMidP);
aLine2->SetSensitivityFactor(10);
theSelection->Add(aLine2);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation(anOwner, myAxes[anIt].DraggerSector().Triangulation(), TopLoc_Location(), Standard_True);
theSelection->Add (aTri);
Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation(anOwner, myAxes[anIt].DraggerSector().Triangulation(), TopLoc_Location(), Standard_True);
theSelection->Add(aTri);
}
break;
}
default:
{
anOwner = new SelectMgr_EntityOwner(this, 5);
break;
}
}
}

View File

@@ -2,8 +2,6 @@ AIS.hxx
AIS_Animation.cxx
AIS_Animation.hxx
AIS_AnimationTimer.hxx
AIS_AnimationAxisRotation.cxx
AIS_AnimationAxisRotation.hxx
AIS_AnimationCamera.cxx
AIS_AnimationCamera.hxx
AIS_AnimationObject.cxx
@@ -14,8 +12,6 @@ AIS_Axis.cxx
AIS_Axis.hxx
AIS_BadEdgeFilter.cxx
AIS_BadEdgeFilter.hxx
AIS_BaseAnimationObject.cxx
AIS_BaseAnimationObject.hxx
AIS_C0RegularityFilter.cxx
AIS_C0RegularityFilter.hxx
AIS_CameraFrustum.cxx

View File

@@ -248,178 +248,167 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
//
// Build the shells
aItF.Initialize (aLFConnected);
for (i = 1; aItF.More() && !bAllFacesTaken; aItF.Next(), ++i)
{
for (i = 1; aItF.More() && !bAllFacesTaken; aItF.Next(), ++i) {
const TopoDS_Shape& aFF = aItF.Value();
if (!AddedFacesMap.Add(aFF)) {
continue;
}
//
// make a new shell
TopoDS_Shell aShell;
aBB.MakeShell(aShell);
aBB.Add(aShell, aFF);
aMEFP.Clear();
TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEFP);
TopoDS_Shell aShellStart;
aBB.MakeShell(aShellStart);
aBB.Add(aShellStart, aFF);
//
// loop on faces added to Shell;
// add their neighbor faces to Shell and so on
aItS.Initialize(aShell);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Face& aF = (*(TopoDS_Face*)(&aItS.Value()));
Standard_Boolean isBoundary = aBoundaryFaces.Contains (aF);
TopTools_ListOfShape aLShells;
aLShells.Append(aShellStart);
//
TopTools_ListIteratorOfListOfShape aItLShells(aLShells);
for (; aItLShells.More(); aItLShells.Next()) {
TopoDS_Shell& aShell = TopoDS::Shell(aItLShells.ChangeValue());
//
// loop on edges of aF; find a good neighbor face of aF by aE
aExp.Init(aF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aExp.Current()));
aMEFP.Clear();
TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEFP);
//
// loop on faces added to Shell;
// add their neighbor faces to Shell and so on
aItS.Initialize(aShell);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Face& aF = (*(TopoDS_Face*)(&aItS.Value()));
Standard_Boolean isBoundary = aBoundaryFaces.Contains (aF);
//
// proceed only free edges in this shell
if (aMEFP.Contains(aE)) {
const TopTools_ListOfShape& aLFP = aMEFP.FindFromKey(aE);
aNbFP = aLFP.Extent();
if (aNbFP > 1) {
// loop on edges of aF; find a good neighbor face of aF by aE
aExp.Init(aF, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aExp.Current()));
//
// proceed only free edges in this shell
if (aMEFP.Contains(aE)) {
const TopTools_ListOfShape& aLFP = aMEFP.FindFromKey(aE);
aNbFP = aLFP.Extent();
if (aNbFP > 1) {
continue;
}
}
// avoid processing of internal edges
anOr = aE.Orientation();
if (anOr == TopAbs_INTERNAL) {
continue;
}
}
// avoid processing of internal edges
anOr = aE.Orientation();
if (anOr == TopAbs_INTERNAL) {
continue;
}
// avoid processing of degenerated edges
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
// candidate faces list
const TopTools_ListOfShape& aLF = aEFMap.FindFromKey(aE);
aNbLF = aLF.Extent();
if (!aNbLF) {
continue;
}
//
// prepare for selecting the next face
// take only not-processed faces as a candidates
BOPTools_ListOfCoupleOfShape aLCSOff;
//
Standard_Integer aNbWaysInside = 0;
TopoDS_Face aSelF;
TopTools_ListIteratorOfListOfShape aItLF(aLF);
for (; aItLF.More(); aItLF.Next()) {
const TopoDS_Face& aFL = (*(TopoDS_Face*)(&aItLF.Value()));
if (aF.IsSame(aFL) || AddedFacesMap.Contains(aFL)) {
// avoid processing of degenerated edges
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
// find current edge in the face
if (!BOPTools_AlgoTools::GetEdgeOff(aE, aFL, aEL)) {
// candidate faces list
const TopTools_ListOfShape& aLF = aEFMap.FindFromKey(aE);
aNbLF = aLF.Extent();
if (!aNbLF) {
continue;
}
//
if (isBoundary && !aBoundaryFaces.Contains (aFL))
// prepare for selecting the next face
// take only not-processed faces as a candidates
BOPTools_ListOfCoupleOfShape aLCSOff;
//
Standard_Integer aNbWaysInside = 0;
TopoDS_Face aSelF;
TopTools_ListIteratorOfListOfShape aItLF(aLF);
for (; aItLF.More(); aItLF.Next()) {
const TopoDS_Face& aFL = (*(TopoDS_Face*)(&aItLF.Value()));
if (aF.IsSame(aFL) || AddedFacesMap.Contains(aFL)) {
continue;
}
//
// find current edge in the face
if (!BOPTools_AlgoTools::GetEdgeOff(aE, aFL, aEL)) {
continue;
}
//
if (isBoundary && !aBoundaryFaces.Contains (aFL))
{
++aNbWaysInside;
aSelF = aFL;
}
aCSOff.SetShape1(aEL);
aCSOff.SetShape2(aFL);
aLCSOff.Append(aCSOff);
}//for (; aItLF.More(); aItLF.Next()) {
//
aNbOff = aLCSOff.Extent();
if (!aNbOff){
continue;
}
//
// among all the adjacent faces chose one with the minimal
// angle to the current one
if (!isBoundary || aNbWaysInside != 1)
{
++aNbWaysInside;
aSelF = aFL;
if (aNbOff == 1) {
aSelF = (*(TopoDS_Face*)(&aLCSOff.First().Shape2()));
}
else if (aNbOff > 1) {
BOPTools_AlgoTools::GetFaceOff(aE, aF, aLCSOff, aSelF, aContext);
}
}
aCSOff.SetShape1(aEL);
aCSOff.SetShape2(aFL);
aLCSOff.Append(aCSOff);
}//for (; aItLF.More(); aItLF.Next()) {
//
aNbOff = aLCSOff.Extent();
if (!aNbOff){
continue;
}
//
// among all the adjacent faces chose one with the minimal
// angle to the current one
if (!isBoundary || aNbWaysInside != 1)
{
if (aNbOff == 1) {
aSelF = (*(TopoDS_Face*)(&aLCSOff.First().Shape2()));
//
if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) {
aBB.Add(aShell, aSelF);
TopExp::MapShapesAndAncestors(aSelF, TopAbs_EDGE, TopAbs_FACE, aMEFP);
}
else if (aNbOff > 1) {
BOPTools_AlgoTools::GetFaceOff(aE, aF, aLCSOff, aSelF, aContext);
}
}
//
if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) {
aBB.Add(aShell, aSelF);
TopExp::MapShapesAndAncestors(aSelF, TopAbs_EDGE, TopAbs_FACE, aMEFP);
}
} // for (; aExp.More(); aExp.Next()) {
} // for (; aItS.More(); aItS.Next()) {
//
// split the shell on multi-connected edges
TopTools_ListOfShape aLShSp;
RefineShell(aShell, aMEFP, aLShSp);
//
// collect the not closed shells for further processing
TopTools_ListOfShape aLShNC;
//
TopTools_ListIteratorOfListOfShape aItLShSp(aLShSp);
for (; aItLShSp.More(); aItLShSp.Next()) {
TopoDS_Shell& aShSp = *((TopoDS_Shell*)&aItLShSp.Value());
} // for (; aExp.More(); aExp.Next()) {
} // for (; aItS.More(); aItS.Next()) {
//
if (BRep_Tool::IsClosed(aShSp)) {
aShSp.Closed(Standard_True);
myLoops.Append(aShSp);
// split the shell on multi-connected edges
TopTools_ListOfShape aLShSp;
RefineShell(aShell, aMEFP, aLShSp);
//
// collect the not closed shells for further processing
TopTools_ListOfShape aLShNC;
//
TopTools_ListIteratorOfListOfShape aItLShSp(aLShSp);
for (; aItLShSp.More(); aItLShSp.Next()) {
TopoDS_Shell& aShSp = *((TopoDS_Shell*)&aItLShSp.Value());
//
if (BRep_Tool::IsClosed(aShSp)) {
aShSp.Closed(Standard_True);
myLoops.Append(aShSp);
}
else {
aLShNC.Append(aShSp);
}
}
else {
aLShNC.Append(aShSp);
//
bAllFacesTaken = (AddedFacesMap.Extent() == aNbShapes);
if (bAllFacesTaken) {
break;
}
}
//
bAllFacesTaken = (AddedFacesMap.Extent() == aNbShapes);
if (bAllFacesTaken) {
break;
}
//
if (aLShSp.Extent() == 1) {
// not further processing of not closed shells is needed,
// as it will not bring any new results
continue;
}
//
// remove th faces of not closed shells from the map of processed faces
// and try to rebuild the shells using all not processed faces,
// because faces of one shell might be needed for building the other
TopTools_ListIteratorOfListOfShape aItLShNC(aLShNC);
for (; aItLShNC.More(); aItLShNC.Next())
{
TopoDS_Iterator aItNC(aItLShNC.Value());
for (; aItNC.More(); aItNC.Next())
{
AddedFacesMap.Remove(aItNC.Value());
//
if (aLShSp.Extent() == 1) {
// not further processing of not closed shells is needed,
// as it will not bring any new results
continue;
}
//
Standard_Integer aNbShNC = aLShNC.Extent();
if (aNbShNC == 1) {
// try to complete the shell with other faces
aLShells.Append(aLShNC);
}
else if (aNbShNC > 1) {
// remove th faces of not closed shells from the map of processed faces
// and try to rebuild the shells using all not processed faces,
// because faces of one shell might be needed for building the other
TopTools_ListIteratorOfListOfShape aItLShNC(aLShNC);
for (; aItLShNC.More(); aItLShNC.Next()) {
TopoDS_Iterator aItNC(aItLShNC.Value());
for (; aItNC.More(); aItNC.Next()) {
AddedFacesMap.Remove(aItNC.Value());
}
}
}
}
} // for (; aItF.More(); aItF.Next()) {
}
//=======================================================================
//function : FindShape
//purpose :
//=======================================================================
TopoDS_Shape FindShape (const TopoDS_Shape& theShapeToFind,
const TopoDS_Shape& theShape)
{
TopoDS_Shape aRes;
TopExp_Explorer anExp(theShape, theShapeToFind.ShapeType());
for (; anExp.More(); anExp.Next())
{
const TopoDS_Shape& aShape = anExp.Current();
if (aShape.IsSame(theShapeToFind))
{
aRes = aShape;
break;
}
}
return aRes;
}
//=======================================================================
//function : RefineShell
//purpose :
@@ -445,21 +434,6 @@ void RefineShell(TopoDS_Shell& theShell,
aMEStop.Add(aE);
continue;
}
if (aLF.Extent() == 2)
{
const TopoDS_Face& aF1 = TopoDS::Face(aLF.First());
const TopoDS_Face& aF2 = TopoDS::Face(aLF.Last());
TopoDS_Shape aE1 = FindShape(aE, aF1);
TopoDS_Shape aE2 = FindShape(aE, aF2);
if (aE1.Orientation() == aE2.Orientation())
{
aMEStop.Add(aE);
continue;
}
}
//
// check for internal edges - count faces, in which the edge
// is internal, twice

View File

@@ -60,7 +60,7 @@ public: //! @name public interfaces
//! Clears the indices
void Clear()
{
myPairs.clear();
myPairs.Clear();
}
//! Sorts the indices

View File

@@ -127,14 +127,6 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria
for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE); ex.More(); ex.Next())
{
const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
if (!useTriangulation && BRep_Tool::IsGeometric(E))
{
BC.Initialize(E);
BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(E), B);
continue;
}
Handle(Poly_Polygon3D) P3d = BRep_Tool::Polygon3D(E, l);
if (!P3d.IsNull() && P3d->NbNodes() > 0)
{
@@ -151,7 +143,7 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria
else
{
BRep_Tool::PolygonOnTriangulation(E, Poly, T, l);
if (!Poly.IsNull() && !T.IsNull() && T->NbNodes() > 0)
if (useTriangulation && !Poly.IsNull() && !T.IsNull() && T->NbNodes() > 0)
{
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
nbNodes = Indices.Length();

View File

@@ -351,10 +351,6 @@ static void TrimEdge (const TopoDS_Edge& CurrentEdge,
for (j=1; j<=ndec; j++) {
// piece of edge
m1 = (CutValues.Value(j)-t0)*(last-first)/(t1-t0)+first;
if (Abs(m0 - m1) < Precision::Confusion())
{
return;
}
TopoDS_Edge CutE = BRepLib_MakeEdge(C,V0,Vbid,m0,m1);
CutE.Orientation(CurrentOrient);
S.Append(CutE);
@@ -362,10 +358,6 @@ static void TrimEdge (const TopoDS_Edge& CurrentEdge,
V0 = TopExp::LastVertex(CutE);
if (j==ndec) {
// last piece
if (Abs(m0 - last) < Precision::Confusion())
{
return;
}
TopoDS_Edge LastE = BRepLib_MakeEdge(C,V0,Vl,m0,last);
LastE.Orientation(CurrentOrient);
S.Append(LastE);
@@ -379,10 +371,6 @@ static void TrimEdge (const TopoDS_Edge& CurrentEdge,
for (j=ndec; j>=1; j--) {
// piece of edge
m0 = (CutValues.Value(j)-t0)*(last-first)/(t1-t0)+first;
if (Abs(m0 - m1) < Precision::Confusion())
{
return;
}
TopoDS_Edge CutE = BRepLib_MakeEdge(C,Vbid,V1,m0,m1);
CutE.Orientation(CurrentOrient);
S.Append(CutE);
@@ -390,10 +378,6 @@ static void TrimEdge (const TopoDS_Edge& CurrentEdge,
V1 = TopExp::FirstVertex(CutE);
if (j==1) {
// last piece
if (Abs(first - m1) < Precision::Confusion())
{
return;
}
TopoDS_Edge LastE = BRepLib_MakeEdge(C,Vf,V1,first,m1);
LastE.Orientation(CurrentOrient);
S.Append(LastE);
@@ -563,10 +547,6 @@ static Standard_Boolean EdgeIntersectOnWire (const gp_Pnt& P1,
SR.Clear();
SR.Append(param);
TrimEdge(E,SR,first,last,SO,SE);
if (SE.IsEmpty())
{
return Standard_False;
}
theEdgeNewEdges(E) = SE;
TopoDS_Vertex VV1,VV2;
TopExp::Vertices(TopoDS::Edge(SE.Value(1)),VV1,VV2);
@@ -701,7 +681,7 @@ void BRepFill_CompatibleWires::Init(const TopTools_SequenceOfShape& Sections)
{
myInit = Sections;
myWork = Sections;
myPercent = 0.1;
myPercent = 0.01;
myStatus = BRepFill_ThruSectionErrorStatus_NotDone;
myMap.Clear();

View File

@@ -76,8 +76,137 @@ namespace {
theBox.Add( thePnt2 );
theBox.Enlarge(Precision);
}
//=============================================================================
//function : IntSegSeg
//purpose : Checks intersection between the two segments.
//=============================================================================
BRepMesh_GeomTool::IntFlag IntSegSeg(
const Handle(BRepMesh_DataStructureOfDelaun)& theMeshData,
const BRepMesh_Edge& theEdg1,
const BRepMesh_Edge& theEdg2,
const Standard_Boolean isConsiderEndPointTouch,
const Standard_Boolean isConsiderPointOnEdge,
gp_Pnt2d& theIntPnt)
{
gp_XY p1, p2, p3, p4;
p1 = theMeshData->GetNode( theEdg1.FirstNode() ).Coord();
p2 = theMeshData->GetNode( theEdg1.LastNode () ).Coord();
p3 = theMeshData->GetNode( theEdg2.FirstNode() ).Coord();
p4 = theMeshData->GetNode( theEdg2.LastNode () ).Coord();
return BRepMesh_GeomTool::IntSegSeg( p1, p2, p3, p4,
isConsiderEndPointTouch, isConsiderPointOnEdge, theIntPnt );
}
} // anonymous namespace
//! Checks polygon links for intersection with current one of the same polygon.
class BRepMesh_Delaun::EBTreeOfB2d_Selector :
public NCollection_EBTree<Standard_Integer, Bnd_B2d>::Selector
{
public:
//! Constructor.
EBTreeOfB2d_Selector(
const Handle(BRepMesh_DataStructureOfDelaun)& theMeshData,
const DataMapOfPVoid& theSegmentsPolyMap,
const Standard_Boolean isConsiderEndPointTouch = Standard_False,
const Standard_Boolean isConsiderPointOnEdge = Standard_False)
: myMeshData ( theMeshData ),
mySegmentsPolyMap ( theSegmentsPolyMap ),
myConsiderEndPointTouch ( isConsiderEndPointTouch ),
myConsiderPointOnEdge ( isConsiderPointOnEdge ),
myPolygonPtr ( nullptr )
{
}
//! Implementation of rejection method
//! @return
//! True if the bounding box does not intersect with the current
virtual Standard_Boolean Reject (const Bnd_B2d& theBox) const
{
return (myBox.IsOut( theBox ));
}
//! Implementation of acceptance method
//! This method is called when the bounding box intersect with the current.
//! It stores the object - the index of box in the list of accepted objects.
//! @return
//! True, because the object is accepted
virtual Standard_Boolean Accept (const Standard_Integer& theObj)
{
if (mySkipLinks.Contains( theObj ))
{
return Standard_False;
}
auto aPtr = mySegmentsPolyMap.Seek( theObj );
if (aPtr != nullptr && *aPtr == myPolygonPtr)
{
const BRepMesh_Edge& aPolyLink = myMeshData->GetLink( Abs( theObj ) );
if (!myLink.IsEqual( aPolyLink ))
{
// intersection is possible...
gp_Pnt2d anIntPnt;
BRepMesh_GeomTool::IntFlag aIntFlag = IntSegSeg(
myMeshData, myLink, aPolyLink,
myConsiderEndPointTouch, myConsiderPointOnEdge, anIntPnt );
myStop = (aIntFlag != BRepMesh_GeomTool::NoIntersection);
return myStop;
}
}
return Standard_False;
}
//! Set current box to search for overlapping with him
void SetCurrent (const BRepMesh_Edge& theLink,
const Bnd_B2d& theBox,
const void* thePolygonPtr)
{
mySkipLinks.Clear();
myStop = Standard_False;
myLink = theLink;
myBox = theBox;
myPolygonPtr = thePolygonPtr;
}
void SetSkipLink(const int theLink)
{
mySkipLinks.Add( theLink );
}
template<typename... T>
void SetSkipLink( const int theLink, const T... theLinks )
{
SetSkipLink( theLink );
SetSkipLink( theLinks... );
}
//! Returns true if the current segment intersects another one of the same polygon.
Standard_Boolean IsIntersected()
{
return myStop;
}
protected:
const Handle(BRepMesh_DataStructureOfDelaun)& myMeshData;
const DataMapOfPVoid& mySegmentsPolyMap;
const Standard_Boolean myConsiderEndPointTouch;
const Standard_Boolean myConsiderPointOnEdge;
const void* myPolygonPtr;
BRepMesh_Edge myLink;
Bnd_B2d myBox;
NCollection_Map<Standard_Integer> mySkipLinks;
};
//=======================================================================
//function : BRepMesh_Delaun
//purpose :
@@ -1883,24 +2012,31 @@ void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon,
}
}
IMeshData::SequenceOfInteger* aPolygon1 = &thePolygon;
IMeshData::SequenceOfBndB2d* aPolyBoxes1 = &thePolyBoxes;
SegmentsBoxes aSegmentsBoxes;
EBTreeOfB2dFiller aTreeFiller( aSegmentsBoxes.Boxes );
Handle(IMeshData::SequenceOfInteger) aPolygon2 = new IMeshData::SequenceOfInteger;
Handle(IMeshData::SequenceOfBndB2d) aPolyBoxes2 = new IMeshData::SequenceOfBndB2d;
Standard_Integer aLinkIt = thePolygon.Lower();
for (; aLinkIt <= thePolygon.Upper(); ++aLinkIt)
{
const Standard_Integer aLinkInfo = thePolygon( aLinkIt );
aTreeFiller .Add (aLinkInfo, thePolyBoxes( aLinkIt ));
aSegmentsBoxes.Rebind(aLinkInfo, &thePolygon);
}
aTreeFiller.Fill();
IMeshData::SequenceOfInteger* aPolygon1 = &thePolygon;
Handle(IMeshData::SequenceOfInteger) aPolygon2 = new IMeshData::SequenceOfInteger;
NCollection_Sequence<Handle(IMeshData::SequenceOfInteger)> aPolyStack;
NCollection_Sequence<Handle(IMeshData::SequenceOfBndB2d)> aPolyBoxStack;
for (;;)
{
decomposeSimplePolygon(*aPolygon1, *aPolyBoxes1, *aPolygon2, *aPolyBoxes2);
decomposeSimplePolygon(*aPolygon1, *aPolygon2, aSegmentsBoxes);
if (!aPolygon2->IsEmpty())
{
aPolyStack.Append(aPolygon2);
aPolyBoxStack.Append(aPolyBoxes2);
aPolygon2 = new IMeshData::SequenceOfInteger;
aPolyBoxes2 = new IMeshData::SequenceOfBndB2d;
aPolygon2 = new IMeshData::SequenceOfInteger;
}
if (aPolygon1->IsEmpty())
@@ -1908,14 +2044,12 @@ void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon,
if (!aPolyStack.IsEmpty() && aPolygon1 == &(*aPolyStack.First()))
{
aPolyStack.Remove(1);
aPolyBoxStack.Remove(1);
}
if (aPolyStack.IsEmpty())
break;
aPolygon1 = &(*aPolyStack.ChangeFirst());
aPolyBoxes1 = &(*aPolyBoxStack.ChangeFirst());
aPolygon1 = &(*aPolyStack.ChangeFirst());
}
}
}
@@ -1964,17 +2098,54 @@ Standard_Boolean BRepMesh_Delaun::meshElementaryPolygon(
//function : meshSimplePolygon
//purpose :
//=======================================================================
namespace
{
struct Candidate
{
Standard_Integer PivotNode;
Standard_Integer LinkId;
Standard_Real Dist;
Standard_Real Angle;
Candidate()
: PivotNode (0),
LinkId (0),
Dist (RealLast()),
Angle (0.)
{
}
Candidate(const Standard_Integer thePivotNode,
const Standard_Integer theLinkId,
const Standard_Real theDist,
const Standard_Real theAngle)
: PivotNode (thePivotNode),
LinkId (theLinkId),
Dist (theDist),
Angle (theAngle)
{
}
bool operator<(const Candidate& theOther) const
{
const bool isWorse = ((Dist >= theOther.Dist) &&
(Angle <= theOther.Angle || Angle > AngDeviation90Deg));
return !isWorse;
}
};
}
void BRepMesh_Delaun::decomposeSimplePolygon(
IMeshData::SequenceOfInteger& thePolygon,
IMeshData::SequenceOfBndB2d& thePolyBoxes,
IMeshData::SequenceOfInteger& thePolygonCut,
IMeshData::SequenceOfBndB2d& thePolyBoxesCut)
SegmentsBoxes& theSegmentsBoxes)
{
// Check is the given polygon elementary
if ( meshElementaryPolygon( thePolygon ) )
{
theSegmentsBoxes.Rebind( thePolygon, nullptr );
thePolygon.Clear();
thePolyBoxes.Clear();
return;
}
@@ -1994,8 +2165,8 @@ void BRepMesh_Delaun::decomposeSimplePolygon(
Standard_Real aRefEdgeLen = aRefEdgeDir.Magnitude();
if ( aRefEdgeLen < Precision )
{
theSegmentsBoxes.Rebind( thePolygon, nullptr );
thePolygon.Clear();
thePolyBoxes.Clear();
return;
}
@@ -2003,19 +2174,16 @@ void BRepMesh_Delaun::decomposeSimplePolygon(
// Find a point with minimum distance respect
// the end of reference link
Standard_Integer aUsedLinkId = 0;
Standard_Real aOptAngle = 0.0;
Standard_Real aMinDist = RealLast();
Standard_Integer aPivotNode = aNodes[1];
Standard_Integer aPolyLen = thePolygon.Length();
for ( Standard_Integer aLinkIt = 3; aLinkIt <= aPolyLen; ++aLinkIt )
{
Standard_Integer aLinkInfo = thePolygon( aLinkIt );
const BRepMesh_Edge& aNextEdge = GetEdge( Abs( aLinkInfo ) );
NCollection_Vector<Candidate> aCandidates( thePolygon.Length() );
aPivotNode = aLinkInfo > 0 ?
for ( Standard_Integer aLinkIt = 3; aLinkIt <= thePolygon.Length(); ++aLinkIt )
{
const Standard_Integer aLinkInfo = thePolygon( aLinkIt );
const BRepMesh_Edge& aNextEdge = GetEdge( Abs( aLinkInfo ) );
const Standard_Integer aPivotNode = aLinkInfo > 0 ?
aNextEdge.FirstNode() :
aNextEdge.LastNode();
aNextEdge.LastNode ();
// We have end points touch case in the polygon - ignore it
if (aPivotNode == aNodes[1])
@@ -2025,55 +2193,43 @@ void BRepMesh_Delaun::decomposeSimplePolygon(
gp_Vec2d aDistanceDir( aRefVertices[1], aPivotVertex );
Standard_Real aDist = aRefEdgeDir ^ aDistanceDir;
Standard_Real aAngle = Abs( aRefEdgeDir.Angle(aDistanceDir) );
Standard_Real aAngle = Abs( aRefEdgeDir.Angle( aDistanceDir ) );
Standard_Real anAbsDist = Abs( aDist );
if (anAbsDist < Precision || aDist < 0.)
continue;
if ( ( anAbsDist >= aMinDist ) &&
( aAngle <= aOptAngle || aAngle > AngDeviation90Deg ) )
{
continue;
}
aCandidates.Append( Candidate{ aPivotNode, aLinkIt, anAbsDist, aAngle });
}
std::sort( aCandidates.begin(), aCandidates.end() );
Standard_Integer aUsedLinkId = 0;
EBTreeOfB2d_Selector aSelector( myMeshData, theSegmentsBoxes.PolyMap );
Standard_Integer aCandIt = aCandidates.Lower();
for (; aCandIt <= aCandidates.Upper(); ++aCandIt)
{
const Candidate& aCand = aCandidates.Value( aCandIt );
const gp_Pnt2d& aPivotVertex = GetVertex( aCand.PivotNode ).Coord();
// Check is the test link crosses the polygon boundaries
Standard_Boolean isIntersect = Standard_False;
for ( Standard_Integer aRefLinkNodeIt = 0; aRefLinkNodeIt < 2; ++aRefLinkNodeIt )
{
const Standard_Integer& aLinkFirstNode = aNodes[aRefLinkNodeIt];
const Standard_Integer& aLinkFirstNode = aNodes [aRefLinkNodeIt];
const gp_Pnt2d& aLinkFirstVertex = aRefVertices[aRefLinkNodeIt];
Bnd_B2d aBox;
UpdateBndBox(aLinkFirstVertex.Coord(), aPivotVertex.Coord(), aBox);
UpdateBndBox( aLinkFirstVertex.Coord(), aPivotVertex.Coord(), aBox );
BRepMesh_Edge aCheckLink( aLinkFirstNode, aPivotNode, BRepMesh_Free );
BRepMesh_Edge aCheckLink( aLinkFirstNode, aCand.PivotNode, BRepMesh_Free );
Standard_Integer aCheckLinkIt = 2;
for ( ; aCheckLinkIt <= aPolyLen; ++aCheckLinkIt )
{
if( aCheckLinkIt == aLinkIt )
continue;
if ( !aBox.IsOut( thePolyBoxes.Value( aCheckLinkIt ) ) )
{
const BRepMesh_Edge& aPolyLink =
GetEdge( Abs( thePolygon( aCheckLinkIt ) ) );
aSelector.SetCurrent ( aCheckLink, aBox, &thePolygon );
aSelector.SetSkipLink( thePolygon.First(), thePolygon( aCand.LinkId ) );
if ( aCheckLink.IsEqual( aPolyLink ) )
continue;
// intersection is possible...
gp_Pnt2d anIntPnt;
BRepMesh_GeomTool::IntFlag aIntFlag = intSegSeg( aCheckLink, aPolyLink,
Standard_False, Standard_False, anIntPnt );
if( aIntFlag != BRepMesh_GeomTool::NoIntersection )
{
isIntersect = Standard_True;
break;
}
}
}
theSegmentsBoxes.Boxes.Select( aSelector );
isIntersect = aSelector.IsIntersected();
if ( isIntersect )
break;
@@ -2083,17 +2239,16 @@ void BRepMesh_Delaun::decomposeSimplePolygon(
continue;
aOptAngle = aAngle;
aMinDist = anAbsDist;
aNodes[2] = aPivotNode;
aNodes [2] = aCand.PivotNode;
aRefVertices[2] = aPivotVertex;
aUsedLinkId = aLinkIt;
aUsedLinkId = aCand.LinkId;
break;
}
if ( aUsedLinkId == 0 )
{
theSegmentsBoxes.Rebind( thePolygon, nullptr );
thePolygon.Clear();
thePolyBoxes.Clear();
return;
}
@@ -2112,48 +2267,49 @@ void BRepMesh_Delaun::decomposeSimplePolygon(
for ( Standard_Integer aTriEdgeIt = 0; aTriEdgeIt < 3; ++aTriEdgeIt )
{
const Standard_Integer& anEdgeInfo = aNewEdgesInfo[aTriEdgeIt];
anEdges[aTriEdgeIt] = Abs( anEdgeInfo );
anEdges [aTriEdgeIt] = Abs( anEdgeInfo );
anEdgesOri[aTriEdgeIt] = anEdgeInfo > 0;
}
addTriangle( anEdges, anEdgesOri, aNodes );
if (aUsedLinkId == 3)
{
thePolygon.Remove ( 1 );
thePolyBoxes.Remove( 1 );
theSegmentsBoxes.Rebind( thePolygon.First(), nullptr );
thePolygon .Remove( 1 );
thePolygon.SetValue( 1, -aNewEdgesInfo[2] );
Bnd_B2d aBox;
UpdateBndBox(aRefVertices[0].Coord(), aRefVertices[2].Coord(), aBox);
thePolyBoxes.SetValue( 1, aBox );
UpdateBndBox( aRefVertices[0].Coord(), aRefVertices[2].Coord(), aBox );
theSegmentsBoxes.Add( thePolygon.First(), aBox, &thePolygon );
}
else
{
// Create triangle and split the source polygon on two
// parts (if possible) and mesh each part as independent
// polygon.
if ( aUsedLinkId < aPolyLen )
if ( aUsedLinkId < thePolygon.Length() )
{
thePolygon.Split(aUsedLinkId, thePolygonCut);
thePolygonCut.Prepend( -aNewEdgesInfo[2] );
thePolyBoxes.Split(aUsedLinkId, thePolyBoxesCut);
thePolygon.Split( aUsedLinkId, thePolygonCut );
theSegmentsBoxes.Rebind ( thePolygonCut, &thePolygonCut );
thePolygonCut .Prepend( -aNewEdgesInfo[2] );
Bnd_B2d aBox;
UpdateBndBox(aRefVertices[0].Coord(), aRefVertices[2].Coord(), aBox);
thePolyBoxesCut.Prepend( aBox );
UpdateBndBox( aRefVertices[0].Coord(), aRefVertices[2].Coord(), aBox );
theSegmentsBoxes.Add( thePolygonCut.First(), aBox, &thePolygonCut );
}
else
{
thePolygon.Remove ( aPolyLen );
thePolyBoxes.Remove( aPolyLen );
theSegmentsBoxes.Rebind( thePolygon.Last (), nullptr );
thePolygon .Remove( thePolygon.Length() );
}
thePolygon.SetValue( 1, -aNewEdgesInfo[1] );
Bnd_B2d aBox;
UpdateBndBox(aRefVertices[1].Coord(), aRefVertices[2].Coord(), aBox);
thePolyBoxes.SetValue( 1, aBox );
UpdateBndBox( aRefVertices[1].Coord(), aRefVertices[2].Coord(), aBox );
theSegmentsBoxes.Add( thePolygon.First(), aBox, &thePolygon );
}
}
@@ -2477,13 +2633,7 @@ BRepMesh_GeomTool::IntFlag BRepMesh_Delaun::intSegSeg(
const Standard_Boolean isConsiderPointOnEdge,
gp_Pnt2d& theIntPnt) const
{
gp_XY p1, p2, p3, p4;
p1 = GetVertex( theEdg1.FirstNode() ).Coord();
p2 = GetVertex( theEdg1.LastNode() ).Coord();
p3 = GetVertex( theEdg2.FirstNode() ).Coord();
p4 = GetVertex( theEdg2.LastNode() ).Coord();
return BRepMesh_GeomTool::IntSegSeg(p1, p2, p3, p4,
return IntSegSeg (myMeshData, theEdg1, theEdg2,
isConsiderEndPointTouch, isConsiderPointOnEdge, theIntPnt);
}

View File

@@ -165,6 +165,42 @@ private:
};
typedef NCollection_DataMap<Standard_Integer, IMeshData::MapOfInteger> DataMapOfMap;
typedef NCollection_DataMap<Standard_Integer, void*> DataMapOfPVoid;
typedef NCollection_EBTree <Standard_Integer, Bnd_B2d> EBTreeOfB2d;
typedef NCollection_UBTreeFiller <Standard_Integer, Bnd_B2d> EBTreeOfB2dFiller;
class EBTreeOfB2d_Selector;
struct SegmentsBoxes
{
EBTreeOfB2d Boxes;
DataMapOfPVoid PolyMap;
void Rebind (const Standard_Integer theLinkInfo,
void* const& thePolygonPtr)
{
PolyMap.Bind (theLinkInfo, thePolygonPtr);
}
void Rebind (IMeshData::SequenceOfInteger& thePolygon,
void* const& thePolygonPtr)
{
Standard_Integer aLinkIt = thePolygon.Lower();
for (; aLinkIt <= thePolygon.Upper(); ++aLinkIt)
{
const Standard_Integer aLinkInfo = thePolygon (aLinkIt);
Rebind (aLinkInfo, thePolygonPtr);
}
}
void Add (const Standard_Integer theLinkInfo,
const Bnd_B2d& theBox,
void* const& thePolygonPtr)
{
PolyMap.Bind (theLinkInfo, thePolygonPtr);
Boxes .Add (theLinkInfo, theBox);
}
};
//! Performs initialization of circles cell filter tool.
void initCirclesTool (const Bnd_Box2d& theBox,
@@ -245,14 +281,12 @@ private:
//! In case if source polygon consists of three links, creates new triangle
//! and clears source container.
//! @param thePolygon source polygon to be decomposed (first part of decomposition).
//! @param thePolyBoxes bounding boxes corresponded to source polygon's links.
//! @param thePolygonCut product of decomposition of source polygon (second part of decomposition).
//! @param thePolyBoxesCut bounding boxes corresponded to resulting polygon's links.
//! @param theSegmentsBoxes map of relations between semgents and their polygons.
void decomposeSimplePolygon (
IMeshData::SequenceOfInteger& thePolygon,
IMeshData::SequenceOfBndB2d& thePolyBoxes,
IMeshData::SequenceOfInteger& thePolygonCut,
IMeshData::SequenceOfBndB2d& thePolyBoxesCut);
SegmentsBoxes& theSegmentsBoxes);
//! Triangulation of closed polygon containing only three edges.
Standard_Boolean meshElementaryPolygon (const IMeshData::SequenceOfInteger& thePolygon);

View File

@@ -41,7 +41,6 @@
#include <TopoDS_Vertex.hxx>
#include <TopTools_MapOfShape.hxx>
#include <ChFi3d.hxx>
#include <LocalAnalysis_SurfaceContinuity.hxx>
static void CorrectOrientationOfTangent(gp_Vec& TangVec,
const TopoDS_Vertex& aVertex,
@@ -51,12 +50,6 @@ static void CorrectOrientationOfTangent(gp_Vec& TangVec,
if (aVertex.IsSame(Vlast))
TangVec.Reverse();
}
static Standard_Boolean CheckMixedContinuity (const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace1,
const TopoDS_Face& theFace2,
const Standard_Real theAngTol);
//=======================================================================
//function : BRepOffset_Analyse
//purpose :
@@ -112,168 +105,15 @@ static void EdgeAnalyse(const TopoDS_Edge& E,
}
else
{
Standard_Boolean isTwoSplines = (aSurfType1 == GeomAbs_BSplineSurface || aSurfType1 == GeomAbs_BezierSurface) &&
(aSurfType2 == GeomAbs_BSplineSurface || aSurfType2 == GeomAbs_BezierSurface);
Standard_Boolean isMixedConcavity = Standard_False;
if (isTwoSplines)
{
Standard_Real anAngTol = 0.1;
isMixedConcavity = CheckMixedContinuity(E, F1, F2, anAngTol);
}
if (!isMixedConcavity)
{
if (ChFi3d::IsTangentFaces(E, F1, F2)) //weak condition
{
ConnectType = ChFiDS_Tangential;
}
else
{
ConnectType = ChFi3d::DefineConnectType(E, F1, F2, SinTol, Standard_False);
}
}
if (ChFi3d::IsTangentFaces(E, F1, F2)) //weak condition
ConnectType = ChFiDS_Tangential;
else
{
ConnectType = ChFiDS_Mixed;
}
ConnectType = ChFi3d::DefineConnectType(E, F1, F2, SinTol, Standard_False);
}
I.Type(ConnectType);
LI.Append(I);
}
//=======================================================================
//function : CheckMixedConcavity
//purpose :
//=======================================================================
Standard_Boolean CheckMixedContinuity (const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace1,
const TopoDS_Face& theFace2,
const Standard_Real theAngTol)
{
Standard_Boolean aMixedCont = Standard_False;
GeomAbs_Shape aCurrOrder = BRep_Tool::Continuity(theEdge, theFace1, theFace2);
if (aCurrOrder > GeomAbs_C0)
{
//Method BRep_Tool::Continuity(...) always returns minimal continuity between faces
//so, if aCurrOrder > C0 it means that faces are tangent along whole edge.
return aMixedCont;
}
//But we caqnnot trust result, if it is C0. because this value set by default.
Standard_Real TolC0 = Max(0.001, 1.5*BRep_Tool::Tolerance(theEdge));
Standard_Real aFirst;
Standard_Real aLast;
Handle(Geom2d_Curve) aC2d1, aC2d2;
if (!theFace1.IsSame(theFace2) &&
BRep_Tool::IsClosed(theEdge, theFace1) &&
BRep_Tool::IsClosed(theEdge, theFace2))
{
//Find the edge in the face 1: this edge will have correct orientation
TopoDS_Edge anEdgeInFace1;
TopoDS_Face aFace1 = theFace1;
aFace1.Orientation(TopAbs_FORWARD);
TopExp_Explorer anExplo(aFace1, TopAbs_EDGE);
for (; anExplo.More(); anExplo.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge(anExplo.Current());
if (anEdge.IsSame(theEdge))
{
anEdgeInFace1 = anEdge;
break;
}
}
if (anEdgeInFace1.IsNull())
{
return aMixedCont;
}
aC2d1 = BRep_Tool::CurveOnSurface(anEdgeInFace1, aFace1, aFirst, aLast);
TopoDS_Face aFace2 = theFace2;
aFace2.Orientation(TopAbs_FORWARD);
anEdgeInFace1.Reverse();
aC2d2 = BRep_Tool::CurveOnSurface(anEdgeInFace1, aFace2, aFirst, aLast);
}
else
{
// Obtaining of pcurves of edge on two faces.
aC2d1 = BRep_Tool::CurveOnSurface(theEdge, theFace1, aFirst, aLast);
//For the case of seam edge
TopoDS_Edge EE = theEdge;
if (theFace1.IsSame(theFace2))
{
EE.Reverse();
}
aC2d2 = BRep_Tool::CurveOnSurface(EE, theFace2, aFirst, aLast);
}
if (aC2d1.IsNull() || aC2d2.IsNull())
{
return aMixedCont;
}
// Obtaining of two surfaces from adjacent faces.
Handle(Geom_Surface) aSurf1 = BRep_Tool::Surface(theFace1);
Handle(Geom_Surface) aSurf2 = BRep_Tool::Surface(theFace2);
if (aSurf1.IsNull() || aSurf2.IsNull())
{
return aMixedCont;
}
Standard_Integer aNbSamples = 23;
// Computation of the continuity.
Standard_Real aPar;
Standard_Real aDelta = (aLast - aFirst) / (aNbSamples - 1);
Standard_Integer i, istart = 1;
Standard_Boolean isG1 = Standard_False;
for (i = 1, aPar = aFirst; i <= aNbSamples; i++, aPar += aDelta)
{
if (i == aNbSamples) aPar = aLast;
LocalAnalysis_SurfaceContinuity aCont(aC2d1, aC2d2, aPar,
aSurf1, aSurf2, GeomAbs_G1, 0.001, TolC0, theAngTol, theAngTol, theAngTol);
if (aCont.IsDone())
{
istart = i + 1;
isG1 = aCont.IsG1();
break;
}
}
if (istart > aNbSamples / 2)
{
return aMixedCont;
}
for (i = istart, aPar = aFirst; i <= aNbSamples; i++, aPar += aDelta)
{
if (i == aNbSamples) aPar = aLast;
LocalAnalysis_SurfaceContinuity aCont(aC2d1, aC2d2, aPar,
aSurf1, aSurf2, GeomAbs_G1, 0.001, TolC0, theAngTol, theAngTol, theAngTol);
if (!aCont.IsDone())
{
continue;
}
if (aCont.IsG1() == isG1)
{
continue;
}
else
{
aMixedCont = Standard_True;
break;
}
}
return aMixedCont;
}
//=======================================================================
//function : BuildAncestors

View File

@@ -29,8 +29,7 @@ enum BRepOffset_Error
BRepOffset_CannotTrimEdges, //!< exception while trim edges
BRepOffset_CannotFuseVertices, //!< exception while fuse vertices
BRepOffset_CannotExtentEdge, //!< exception while extent edges
BRepOffset_UserBreak, //!< user break
BRepOffset_MixedConnectivity //!< Different connectivity of faces along edge: partially C0 and tangent
BRepOffset_UserBreak //!< user break
};
#endif // _BRepOffset_Error_HeaderFile

View File

@@ -910,19 +910,6 @@ void BRepOffset_MakeOffset::MakeOffsetShape(const Message_ProgressRange& theRang
myAnalyse.SetFaceOffsetMap (myFaceOffset);
}
myAnalyse.Perform(myFaceComp,TolAngle, aPS.Next(aSteps(PIOperation_Analyse)));
TopExp_Explorer anEExp(myFaceComp, TopAbs_EDGE);
for (; anEExp.More(); anEExp.Next())
{
const TopoDS_Edge& anE = TopoDS::Edge(anEExp.Current());
const BRepOffset_ListOfInterval& aLI = myAnalyse.Type(anE);
if (aLI.IsEmpty())
continue;
if (aLI.Last().Type() == ChFiDS_Mixed)
{
myError = BRepOffset_MixedConnectivity;
return;
}
}
if (!aPS.More())
{
myError = BRepOffset_UserBreak;
@@ -2973,36 +2960,6 @@ void BRepOffset_MakeOffset::MakeMissingWalls (const Message_ProgressRange& theRa
TopExp::Vertices(anEdge, V1, V2);
Standard_Real aF, aL;
const Handle(Geom_Curve) aC = BRep_Tool::Curve(anEdge, aF, aL);
if (V3.IsNull() && V4.IsNull())
{
// Initially offset edge is created without vertices.
// Then edge is trimmed by intersection line between
// two adjacent extended offset faces and get vertices.
// When intersection lines are invalid for any reason,
// (one of reson is mixed connectivity of faces)
// algoritm of cutting offset edge by intersection line
// can fail and offset edge cannot get vertices.
// Follwing workaround is only to avoid exeption if V3 and V4 are Null
// Vertex points are invalid.
Standard_Real anOEF, anOEL;
TopAbs_Orientation anOEOri = OE.Orientation();
OE.Orientation(TopAbs_FORWARD);
Handle(Geom_Curve) anOEC = BRep_Tool::Curve(OE, anOEF, anOEL);
BRep_Builder aBB;
gp_Pnt aP1 = anOEC->Value(aF);
gp_Pnt aP2 = anOEC->Value(aL);
TopoDS_Vertex anOEV1, anOEV2;
Standard_Real aTol = Max(BRep_Tool::Tolerance(V1), BRep_Tool::Tolerance(V2));
aBB.MakeVertex(anOEV1, aP1, aTol);
anOEV1.Orientation(TopAbs_FORWARD);
aBB.MakeVertex(anOEV2, aP2, aTol);
anOEV2.Orientation(TopAbs_REVERSED);
aBB.Add(OE, anOEV1);
aBB.Add(OE, anOEV2);
aBB.Range(OE, aF, aL);
OE.Orientation(anOEOri);
TopExp::Vertices(OE, V4, V3);
}
if (!aC.IsNull() &&
(!aC->IsClosed() && !aC->IsPeriodic()))
{

View File

@@ -5225,6 +5225,7 @@ void BRepOffset_BuildOffsetFaces::FilterInvalidEdges (const BRepOffset_DataMapOf
const TopTools_ListOfShape* pEOrigins = myOEOrigins.Seek (aE);
if (!pEOrigins)
{
theMEUseInRebuild.Add (aE);
continue;
}
@@ -5392,29 +5393,6 @@ void BRepOffset_BuildOffsetFaces::FindFacesToRebuild()
}
}
namespace
{
//=======================================================================
//function : mapShapes
//purpose : Collect theVecShapes into theMap with setted theType
//=======================================================================
template<class Container>
static void mapShapes (const Container& theVecShapes,
const TopAbs_ShapeEnum theType,
TopTools_MapOfShape& theMap)
{
for (const auto& aShape : theVecShapes)
{
for (TopExp_Explorer anExp(aShape, theType); anExp.More(); anExp.Next())
{
theMap.Add(anExp.Current());
}
}
}
}
//=======================================================================
//function : IntersectFaces
//purpose : Intersection of the faces that should be rebuild to resolve all invalidities
@@ -5737,10 +5715,7 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces (TopTools_MapOfShape& theVertsT
TopoDS_Compound aCBE;
aBB.MakeCompound (aCBE);
//
// remember inside edges and vertices to further check
TopTools_MapOfShape anInsideEdges;
TopTools_MapOfShape anInsideVertices;
TopExp_Explorer aExp(aCBInv, TopAbs_EDGE);
TopExp_Explorer aExp (aCBInv, TopAbs_EDGE);
for (; aExp.More(); aExp.Next())
{
const TopoDS_Shape& aE = aExp.Current();
@@ -5749,15 +5724,6 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces (TopTools_MapOfShape& theVertsT
if (aMEFence.Add (aE))
{
aBB.Add (aCBE, aE);
if (!myEdgesToAvoid.Contains(aE) && myInvalidEdges.Contains(aE))
{
anInsideEdges.Add(aE);
TopoDS_Iterator anIt(aE);
for (; anIt.More(); anIt.Next())
{
anInsideVertices.Add(anIt.Value());
}
}
}
}
}
@@ -5783,6 +5749,10 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces (TopTools_MapOfShape& theVertsT
TopExp::MapShapes (aCBELoc, TopAbs_EDGE, aME);
aMECV = aME;
TopExp::MapShapes (aCBELoc, TopAbs_VERTEX, aME);
//
// Using the map <aME> find chain of faces to be intersected;
//
// faces for intersection
TopTools_IndexedMapOfShape aMFInt;
// additional faces for intersection
TopTools_IndexedMapOfShape aMFIntExt;
@@ -5831,14 +5801,6 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces (TopTools_MapOfShape& theVertsT
if (pMFInter && !pInterFi)
continue;
// create map of edges and vertices for aLFImi
TopTools_MapOfShape aMEVIm;
mapShapes(*aLFImi, TopAbs_EDGE, aMEVIm);
mapShapes(*aLFImi, TopAbs_VERTEX, aMEVIm);
Standard_Boolean isIContainsE = aMEVIm.HasIntersection(anInsideEdges);
Standard_Boolean isIContainsV = aMEVIm.HasIntersection(anInsideVertices);
for (j = i + 1; j <= aNb; ++j)
{
const TopoDS_Face& aFj = TopoDS::Face (aMFInt (j));
@@ -5858,28 +5820,6 @@ void BRepOffset_BuildOffsetFaces::IntersectFaces (TopTools_MapOfShape& theVertsT
if (!aLFEj)
continue;
// create map of edges and vertices for aLFImi
aMEVIm.Clear();
mapShapes(*aLFImj, TopAbs_EDGE, aMEVIm);
mapShapes(*aLFImj, TopAbs_VERTEX, aMEVIm);
// check images of both faces contain anInsideEdges and anInsideVertices
// not process if false and true
Standard_Boolean isJContainsE = aMEVIm.HasIntersection(anInsideEdges);
Standard_Boolean isJContainsV = aMEVIm.HasIntersection(anInsideVertices);
// Check if one face is connected to inside edge then
// the other must be also connected
if ((isIContainsE && !isJContainsV) ||
(isJContainsE && !isIContainsV))
{
TopTools_ListOfShape aLVC;
// it is necessary to process the images if they already have
// common vertices
FindCommonParts(*aLFImi, *aLFImj, aLVC, TopAbs_VERTEX);
if (aLVC.IsEmpty())
continue;
}
//
// if there are some common edges between faces
// we should use these edges and do not intersect again.

View File

@@ -281,11 +281,9 @@ static Standard_Integer mkedge(Draw_Interpretor& di, Standard_Integer n, const c
Handle(Geom_Curve) C = DrawTrSurf::GetCurve(a[2]);
Handle(Geom2d_Curve) C2d = DrawTrSurf::GetCurve2d(a[2]);
Handle(Poly_Polygon3D) P3d = DrawTrSurf::GetPolygon3D(a[2]);
if (C.IsNull() && C2d.IsNull() && P3d.IsNull()) {
if (C.IsNull() && C2d.IsNull()) {
//std::cout << a[2] << " is not a curve" << std::endl;
di << a[2] << " is not a curve or polygon 3d\n";
di << a[2] << " is not a curve\n";
return 1;
}
@@ -293,12 +291,7 @@ static Standard_Integer mkedge(Draw_Interpretor& di, Standard_Integer n, const c
if (n == 3) {
if (!C.IsNull()) edge = BRepBuilderAPI_MakeEdge(C);
else if (!C2d.IsNull()) edge = BRepBuilderAPI_MakeEdge2d(C2d);
else
{
BRep_Builder aBB;
aBB.MakeEdge(edge, P3d);
}
else edge = BRepBuilderAPI_MakeEdge2d(C2d);
}
else {
Handle(Geom_Surface) S;

View File

@@ -415,11 +415,6 @@ static void reportOffsetState(Draw_Interpretor& theCommands,
theCommands << "ERROR. Can not extent edge.";
break;
}
case BRepOffset_MixedConnectivity:
{
theCommands << "ERROR. Mixed connectivity of faces.";
break;
}
default:
{
theCommands << "ERROR. offsetperform operation not done.";
@@ -979,10 +974,7 @@ Standard_Integer thickshell(Draw_Interpretor& theCommands,
const BRepOffset_Error aRetCode = B.Error();
reportOffsetState(theCommands, aRetCode);
if (!B.Shape().IsNull())
{
DBRep::Set(a[1], B.Shape());
}
DBRep::Set(a[1], B.Shape());
return 0;
}
@@ -1117,10 +1109,7 @@ Standard_Integer offsetshape(Draw_Interpretor& theCommands,
const BRepOffset_Error aRetCode = B.Error();
reportOffsetState(theCommands, aRetCode);
if (!B.Shape().IsNull())
{
DBRep::Set(a[1], B.Shape());
}
DBRep::Set(a[1], B.Shape());
return 0;
}

View File

@@ -692,6 +692,7 @@ void ChFi3d_Builder::PerformExtremity (const Handle(ChFiDS_Spine)& Spine)
else{
sst = Spine->LastStatus();
iedge = Spine->NbEdges();
E[0] = Spine->Edges(iedge);
V = Spine->LastVertex();
}
//Before all it is checked if the tangency is not dead.
@@ -702,7 +703,6 @@ void ChFi3d_Builder::PerformExtremity (const Handle(ChFiDS_Spine)& Spine)
}
if(sst == ChFiDS_BreakPoint){
Standard_Integer aLocNbG1Connections = 0;
TopTools_ListIteratorOfListOfShape It;//,Jt;
Standard_Boolean sommetpourri = Standard_False;
TopTools_IndexedMapOfOrientedShape EdgesOfV;
@@ -720,10 +720,7 @@ void ChFi3d_Builder::PerformExtremity (const Handle(ChFiDS_Spine)& Spine)
if (!F2.IsNull() && ChFi3d::IsTangentFaces(anEdge, F1, F2, GeomAbs_G2)) //smooth edge
{
if (!F1.IsSame(F2))
{
NbG1Connections++;
aLocNbG1Connections++;
}
continue;
}
@@ -762,7 +759,7 @@ void ChFi3d_Builder::PerformExtremity (const Handle(ChFiDS_Spine)& Spine)
if (EdgesOfV.Extent() != 3)
sommetpourri = Standard_True;
if(!sommetpourri && aLocNbG1Connections < 4){
if(!sommetpourri){
sst = ChFi3d_EdgeState(E,myEFMap);
}
if(ii==1)Spine->SetFirstStatus(sst);

View File

@@ -24,8 +24,7 @@ ChFiDS_Concave,
ChFiDS_Convex,
ChFiDS_Tangential,
ChFiDS_FreeBound,
ChFiDS_Other,
ChFiDS_Mixed
ChFiDS_Other
};
#endif // _ChFiDS_TypeOfConcavity_HeaderFile

View File

@@ -295,18 +295,6 @@ TCollection_AsciiString DE_ConfigurationContext::StringVal(const TCollection_Asc
return GetString(theParam, aVal, theScope) ? aVal : theDefValue;
}
//=======================================================================
//function : StringSeqVal
//purpose :
//=======================================================================
TColStd_ListOfAsciiString DE_ConfigurationContext::StringSeqVal(const TCollection_AsciiString& theParam,
const TColStd_ListOfAsciiString& theDefValue,
const TCollection_AsciiString& theScope) const
{
TColStd_ListOfAsciiString aVal;
return GetStringSeq(theParam, aVal, theScope) ? aVal : theDefValue;
}
//=======================================================================
//function : GetReal
//purpose :

View File

@@ -139,15 +139,6 @@ public:
const TCollection_AsciiString& theDefValue,
const TCollection_AsciiString& theScope = "") const;
//! Gets value of parameter as being of specific type
//! @param[in] theParam complex parameter name
//! @param[in] theDefValue value by default if param is not found or has wrong type
//! @param[in] theScope base parameter name
//! @return specific type value
Standard_EXPORT TColStd_ListOfAsciiString StringSeqVal(const TCollection_AsciiString& theParam,
const TColStd_ListOfAsciiString& theDefValue,
const TCollection_AsciiString& theScope = "") const;
//! Gets internal resource map
//! @return map with resource value
Standard_EXPORT const DE_ResourceMap& GetInternalMap() const { return myResource; }

View File

@@ -114,15 +114,6 @@ bool DE_ConfigurationNode::IsExportSupported() const
return false;
}
//=======================================================================
// function : IsExportSupported
// purpose :
//=======================================================================
bool DE_ConfigurationNode::IsStreamSupported() const
{
return false;
}
//=======================================================================
// function : CheckForSupport
// purpose :

View File

@@ -102,10 +102,6 @@ public:
//! @return Standard_True if export is support
Standard_EXPORT virtual bool IsExportSupported() const;
//! Checks the stream for import/export supporting
//! @return Standard_True if stream is support
Standard_EXPORT virtual bool IsStreamSupported() const;
//! Gets CAD format name of associated provider
//! @return provider CAD format
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const = 0;
@@ -132,11 +128,17 @@ public:
//! Gets the provider loading status
//! @return Standard_True if the load is correct
Standard_Boolean IsEnabled() const { return myIsEnabled; }
Standard_Boolean IsEnabled() const
{
return myIsEnabled;
}
//! Sets the provider loading status
//! @param[in] theIsLoaded input load status
void SetEnabled(const Standard_Boolean theIsLoaded) { myIsEnabled = theIsLoaded; }
void SetEnabled(const Standard_Boolean theIsLoaded)
{
myIsEnabled = theIsLoaded;
}
public:

View File

@@ -47,27 +47,7 @@ Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support read operation";
return Standard_False;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DE_Provider::Read(std::istream& theIStream,
const Handle(TDocStd_Document)& theDocument,
const TCollection_AsciiString theName,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theIStream;
(void)theDocument;
(void)theName;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support stream read operation";
" " << GetVendor() <<" doesn't support read operation";
return Standard_False;
}
@@ -89,21 +69,35 @@ Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
return Standard_False;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
(void)thePath;
(void)theDocument;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support read operation";
return Standard_False;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DE_Provider::Write(std::ostream& theOStream,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
(void)theOStream;
(void)thePath;
(void)theDocument;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support stream write operation";
" " << GetVendor() << " doesn't support write operation";
return Standard_False;
}
@@ -125,26 +119,6 @@ Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
return Standard_False;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DE_Provider::Read(std::istream& theIStream,
TopoDS_Shape& theShape,
const TCollection_AsciiString theName,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theIStream;
(void)theShape;
(void)theName;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support stream read operation";
return Standard_False;
}
//=======================================================================
// function : Write
// purpose :
@@ -163,20 +137,34 @@ Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
return Standard_False;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
(void)thePath;
(void)theShape;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support read operation";
return Standard_False;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DE_Provider::Write(std::ostream& theOStream,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
(void)theOStream;
(void)thePath;
(void)theShape;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support stream write operation";
" " << GetVendor() << " doesn't support write operation";
return Standard_False;
}

View File

@@ -61,23 +61,10 @@ public:
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] theIStream stream to import CAD data
//! @param[out] theDocument document to save result
//! @paramp[in] theName name of CAD file, can be empty
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(std::istream& theIStream,
const Handle(TDocStd_Document)& theDocument,
const TCollection_AsciiString theName,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
@@ -85,21 +72,28 @@ public:
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return True if Write was successful
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] theOStream stream to export CAD data
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(std::ostream& theOStream,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! @return True if Write was successful
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
@@ -107,23 +101,10 @@ public:
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] theIStream stream to the CAD file
//! @param[out] theShape shape to save result
//! @paramp[in] theName name of CAD file, can be empty
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(std::istream& theIStream,
TopoDS_Shape& theShape,
const TCollection_AsciiString theName,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
@@ -131,21 +112,28 @@ public:
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return True if Write was successful
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] theOStream stream to export CAD data
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(std::ostream& theOStream,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! @return True if Write was successful
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
public:
@@ -159,11 +147,17 @@ public:
//! Gets internal configuration node
//! @return configuration node object
Handle(DE_ConfigurationNode) GetNode() const { return myNode; }
Handle(DE_ConfigurationNode) GetNode() const
{
return myNode;
}
//! Sets internal configuration node
//! @param[in] theNode configuration node to set
void SetNode(const Handle(DE_ConfigurationNode)& theNode) { myNode = theNode; }
void SetNode(const Handle(DE_ConfigurationNode)& theNode)
{
myNode = theNode;
}
private:

View File

@@ -31,7 +31,7 @@ namespace
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope("global");
static const TCollection_AsciiString aScope ("global");
return aScope;
}
@@ -109,6 +109,10 @@ Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
{
return Standard_False;
}
if (theWS.IsNull())
{
return Read(thePath, theDocument, theProgress);
}
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_True, aProvider))
{
@@ -130,6 +134,10 @@ Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
{
return Standard_False;
}
if (theWS.IsNull())
{
return Write(thePath, theDocument, theProgress);
}
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_False, aProvider))
{
@@ -138,6 +146,46 @@ Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
return aProvider->Write(thePath, theDocument, theWS, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
return Standard_False;
}
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_True, aProvider))
{
return Standard_False;
}
return aProvider->Read(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
return Standard_False;
}
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_False, aProvider))
{
return Standard_False;
}
return aProvider->Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Read
// purpose :
@@ -147,6 +195,10 @@ Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (theWS.IsNull())
{
return Read(thePath, theShape, theProgress);
}
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_True, aProvider))
{
@@ -164,6 +216,10 @@ Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (theWS.IsNull())
{
return Write(thePath, theShape, theProgress);
}
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_False, aProvider))
{
@@ -172,6 +228,39 @@ Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
return aProvider->Write(thePath, theShape, theWS, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_True, aProvider))
{
return Standard_False;
}
return aProvider->Read(thePath, theShape, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(DE_Provider) aProvider;
if (!FindProvider(thePath, Standard_False, aProvider))
{
return Standard_False;
}
return aProvider->Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Load
// purpose :

View File

@@ -94,6 +94,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
@@ -116,6 +134,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
public:
//! Updates values according the resource file

View File

@@ -51,21 +51,7 @@ bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (theDocument.IsNull())
{
Message::SendFail() << "Error: DEBRepCascade_Provider : "
<< "Null document";
return false;
}
TopoDS_Shape aShape;
if (!Read(thePath, aShape, theWS, theProgress))
{
return false;
}
Handle(XCAFDoc_ShapeTool) aShTool =
XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aShTool->AddShape(aShape);
return true;
return Read(thePath, theDocument, theProgress);
}
//=======================================================================
@@ -78,15 +64,49 @@ bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if(theDocument.IsNull())
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
return false;
}
TopoDS_Shape aShape;
if (!Read(thePath, aShape, theProgress))
{
return false;
}
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aShTool->AddShape(aShape);
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
TopoDS_Shape aShape;
TDF_LabelSequence aLabels;
Handle(XCAFDoc_ShapeTool) aSTool =
XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aSTool->GetFreeShapes(aLabels);
if (aLabels.Length() <= 0)
{
Message::SendFail() << "Error: DEBRepCascade_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Document contain no shapes";
return false;
}
@@ -106,7 +126,7 @@ bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
}
aShape = aComp;
}
return Write(thePath, aShape, theWS, theProgress);
return Write(thePath, aShape, theProgress);
}
//=======================================================================
@@ -119,45 +139,7 @@ bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
bool isBinaryFormat = true;
{
// probe file header to recognize format
const Handle(OSD_FileSystem)& aFileSystem =
OSD_FileSystem::DefaultFileSystem();
std::shared_ptr<std::istream> aFile =
aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
if (aFile.get() == NULL)
{
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Cannot open the file";
return false;
}
char aStringBuf[255] = {};
aFile->read(aStringBuf, 255);
if (aFile->fail())
{
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Cannot open the file";
return false;
}
isBinaryFormat = !(::strncmp(aStringBuf, "DBRep_DrawableShape", 19) == 0);
}
Standard_Boolean aReadStatus = Standard_True;
if (isBinaryFormat)
{
aReadStatus = BinTools::Read(theShape, thePath.ToCString(), theProgress);
}
else
{
aReadStatus =
BRepTools::Read(theShape, thePath.ToCString(), BRep_Builder(), theProgress);
}
if (!aReadStatus)
{
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Cannot read data from the file";
}
return aReadStatus;
return Read(thePath, theShape, theProgress);
}
//=======================================================================
@@ -170,72 +152,127 @@ bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(DEBRepCascade_ConfigurationNode)))
return Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
bool isBinaryFormat = true;
{
Message::SendFail() << "Error: DEBRepCascade_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(DEBRepCascade_ConfigurationNode) aNode =
Handle(DEBRepCascade_ConfigurationNode)::DownCast(GetNode());
if (aNode->InternalParameters.WriteBinary)
{
if (aNode->InternalParameters.WriteVersionBin >
static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_UPPER) ||
aNode->InternalParameters.WriteVersionBin <
static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_LOWER))
// probe file header to recognize format
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
if (aFile.get() == NULL)
{
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Unknown format version";
return false;
}
if (aNode->InternalParameters.WriteNormals &&
aNode->InternalParameters.WriteVersionBin < BinTools_FormatVersion_VERSION_4)
{
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Vertex normals require binary format version 4 or later";
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read the file";
return false;
}
if (!BinTools::Write(theShape, thePath.ToCString(),
aNode->InternalParameters.WriteTriangles,
aNode->InternalParameters.WriteNormals,
aNode->InternalParameters.WriteVersionBin, theProgress))
char aStringBuf[255] = {};
aFile->read(aStringBuf, 255);
if (aFile->fail())
{
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Cannot write the file";
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read the file";
return false;
}
isBinaryFormat = !(::strncmp(aStringBuf, "DBRep_DrawableShape", 19) == 0);
}
if (isBinaryFormat)
{
if (!BinTools::Read(theShape, thePath.ToCString(), theProgress))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read from the file";
return false;
}
}
else
{
if (aNode->InternalParameters.WriteVersionAscii >
static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_UPPER) ||
aNode->InternalParameters.WriteVersionAscii <
static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_LOWER))
if (!BRepTools::Read(theShape, thePath.ToCString(), BRep_Builder(), theProgress))
{
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Unknown format version";
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read from the file";
return false;
}
}
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEBRepCascade_ConfigurationNode)))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(DEBRepCascade_ConfigurationNode) aNode = Handle(DEBRepCascade_ConfigurationNode)::DownCast(GetNode());
if (aNode->InternalParameters.WriteBinary)
{
if (aNode->InternalParameters.WriteVersionBin > static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_UPPER) ||
aNode->InternalParameters.WriteVersionBin < static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_LOWER))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Unknown format version";
return false;
}
if (aNode->InternalParameters.WriteNormals &&
aNode->InternalParameters.WriteVersionBin < BinTools_FormatVersion_VERSION_4)
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Vertex normals require binary format version 4 or later";
return false;
}
if (!BinTools::Write(theShape, thePath.ToCString(), aNode->InternalParameters.WriteTriangles,
aNode->InternalParameters.WriteNormals, aNode->InternalParameters.WriteVersionBin, theProgress))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Cannot write the file";
return false;
}
}
else
{
if (aNode->InternalParameters.WriteVersionAscii > static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_UPPER) ||
aNode->InternalParameters.WriteVersionAscii < static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_LOWER))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Unknown format version";
return false;
}
if (aNode->InternalParameters.WriteNormals &&
aNode->InternalParameters.WriteVersionAscii < TopTools_FormatVersion_VERSION_3)
{
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Vertex normals require ascii format version 3 or later";
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Error: vertex normals require ascii format version 3 or later";
return false;
}
if (!BRepTools::Write(theShape, thePath.ToCString(),
aNode->InternalParameters.WriteTriangles,
aNode->InternalParameters.WriteNormals,
aNode->InternalParameters.WriteVersionAscii, theProgress))
if (!BRepTools::Write(theShape, thePath.ToCString(), aNode->InternalParameters.WriteTriangles,
aNode->InternalParameters.WriteNormals, aNode->InternalParameters.WriteVersionAscii, theProgress))
{
Message::SendFail() << "Error: DEBRepCascade_Provider : ["
<< thePath << "] : Cannot write the file";
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Cannot write the file";
return false;
}
}
return true;
}

View File

@@ -64,6 +64,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
@@ -86,6 +104,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
//! Gets CAD format name of associated provider

View File

@@ -59,21 +59,43 @@ bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Read(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
Message::SendFail() << "Error: DEXCAFCascade_Provider : "
<< "Null document";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
return false;
}
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
{
Message::SendFail() << "Error: DEXCAFCascade_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " << thePath
<< "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(DEXCAFCascade_ConfigurationNode) aNode =
Handle(DEXCAFCascade_ConfigurationNode)::DownCast(GetNode());
Handle(DEXCAFCascade_ConfigurationNode) aNode = Handle(DEXCAFCascade_ConfigurationNode)::DownCast(GetNode());
Handle(TDocStd_Document) aDocument;
Handle(TDocStd_Application) anApp = new TDocStd_Application();
BinDrivers::DefineFormat(anApp);
@@ -86,15 +108,12 @@ bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
XmlLDrivers::DefineFormat(anApp);
XmlTObjDrivers::DefineFormat(anApp);
XmlXCAFDrivers::DefineFormat(anApp);
Handle(PCDM_ReaderFilter) aFilter =
new PCDM_ReaderFilter(aNode->InternalParameters.ReadAppendMode);
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadSkipValues);
anIt.More(); anIt.Next())
Handle(PCDM_ReaderFilter) aFilter = new PCDM_ReaderFilter(aNode->InternalParameters.ReadAppendMode);
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadSkipValues); anIt.More(); anIt.Next())
{
aFilter->AddSkipped(anIt.Value());
}
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadValues);
anIt.More(); anIt.Next())
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadValues); anIt.More(); anIt.Next())
{
if (anIt.Value().StartsWith("0"))
{
@@ -108,8 +127,8 @@ bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
if (anApp->Open(thePath, aDocument, aFilter, theProgress) != PCDM_RS_OK)
{
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Cannot open XDE document";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file : " << thePath
<< "\t: Cannot open XDE document";
return false;
}
theDocument->SetData(aDocument->GetData());
@@ -122,10 +141,8 @@ bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
//=======================================================================
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
Handle(TDocStd_Application) anApp = new TDocStd_Application();
BinXCAFDrivers::DefineFormat(anApp);
PCDM_StoreStatus aStatus = PCDM_SS_Doc_IsNull;
@@ -135,50 +152,50 @@ bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
}
else if (!theDocument->IsSaved())
{
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : Document has never been saved";
Message::SendFail() << "Storage error in the DEXCAFCascade_Provider during writing the file " <<
thePath << "\t: Storage error : this document has never been saved";
return false;
}
else
{
aStatus = anApp->Save(theDocument, theProgress);
}
switch (aStatus)
{
case PCDM_SS_OK:
return true;
case PCDM_SS_DriverFailure:
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : driver failure";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : driver failure";
break;
case PCDM_SS_WriteFailure:
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : write failure";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during the writing the file : " << thePath
<< "\t: Storage error : write failure";
break;
case PCDM_SS_Failure:
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : general failure";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : general failure";
break;
case PCDM_SS_Doc_IsNull:
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : document is NULL";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error :: document is NULL";
break;
case PCDM_SS_No_Obj:
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : no object";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : no object";
break;
case PCDM_SS_Info_Section_Error:
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : section error";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : section error";
break;
case PCDM_SS_UserBreak:
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : user break";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : user break";
break;
case PCDM_SS_UnrecognizedFormat:
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : unrecognized document storage format : "
<< theDocument->StorageFormat();
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : unrecognized document storage format : " << theDocument->StorageFormat();
break;
}
return false;
@@ -194,25 +211,48 @@ bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
return Read(thePath, theShape, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
{
Message::SendFail() << "Error: DEXCAFCascade_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " << thePath
<< "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(TDocStd_Document) aDocument;
Handle(TDocStd_Application) anApp = new TDocStd_Application();
BinXCAFDrivers::DefineFormat(anApp);
anApp->NewDocument("BinXCAF", aDocument);
Read(thePath, aDocument, theWS, theProgress);
Read(thePath, aDocument, theProgress);
TDF_LabelSequence aLabels;
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main());
aSTool->GetFreeShapes(aLabels);
if (aLabels.Length() <= 0)
{
Message::SendFail() << "Error: DEXCAFCascade_Provider : [" <<
thePath << "] : Storage error : Document contain no shapes";
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file : " << thePath
<< "\t: Document contain no shapes";
return false;
}
@@ -241,14 +281,12 @@ bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
//=======================================================================
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
return Write(thePath, aDoc, theWS, theProgress);
return Write(thePath, aDoc, theProgress);
}
//=======================================================================

View File

@@ -64,6 +64,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
@@ -86,6 +104,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
//! Gets CAD format name of associated provider

View File

@@ -429,8 +429,6 @@ static Standard_Boolean ConicDefinition
term2 = -gdet/(cprim*pdet);
if (IsEllip) {
if (term1 <= eps || term2 <= eps)
return Standard_False;
Xax = cost;
Yax = sint;
Rmin = sqrt ( term1);
@@ -441,16 +439,12 @@ static Standard_Boolean ConicDefinition
}
}
else if (term1 <= eps){
if (-term1 <= eps || term2 <= eps)
return Standard_False;
Xax = -sint;
Yax = cost;
Rmin = sqrt (-term1);
Rmax = sqrt (term2);
}
else {
if (term1 <= eps || -term2 <= eps)
return Standard_False;
Xax = cost;
Yax = sint;
Rmin = sqrt (-term2);

View File

@@ -93,15 +93,6 @@ public:
//! converts RLine to Geom(2d)_Curve.
Standard_EXPORT static void TreatRLine (const Handle(IntPatch_RLine)& theRL, const Handle(GeomAdaptor_Surface)& theHS1, const Handle(GeomAdaptor_Surface)& theHS2, Handle(Geom_Curve)& theC3d, Handle(Geom2d_Curve)& theC2d1, Handle(Geom2d_Curve)& theC2d2, Standard_Real& theTolReached);
//! creates 2D-curve on given surface from given 3D-curve
Standard_EXPORT static void BuildPCurves (const Standard_Real theFirst, const Standard_Real theLast,
const Standard_Real theUmin, const Standard_Real theUmax,
const Standard_Real theVmin, const Standard_Real theVmax,
Standard_Real& theTol,
const Handle(Geom_Surface)& theSurface,
const Handle(Geom_Curve)& theCurve,
Handle(Geom2d_Curve)& theCurve2d);
//! creates 2D-curve on given surface from given 3D-curve
Standard_EXPORT static void BuildPCurves (const Standard_Real f, const Standard_Real l, Standard_Real& Tol, const Handle(Geom_Surface)& S, const Handle(Geom_Curve)& C, Handle(Geom2d_Curve)& C2d);

View File

@@ -1074,92 +1074,94 @@ void GeomInt_IntSS::TreatRLine(const Handle(IntPatch_RLine)& theRL,
//function : BuildPCurves
//purpose :
//=======================================================================
void GeomInt_IntSS::BuildPCurves (const Standard_Real theFirst, const Standard_Real theLast,
const Standard_Real theUmin, const Standard_Real theUmax,
const Standard_Real theVmin, const Standard_Real theVmax,
Standard_Real& theTol,
const Handle(Geom_Surface)& theSurface,
const Handle(Geom_Curve)& theCurve,
Handle(Geom2d_Curve)& theCurve2d)
void GeomInt_IntSS::BuildPCurves (Standard_Real f,
Standard_Real l,
Standard_Real& Tol,
const Handle (Geom_Surface)& S,
const Handle (Geom_Curve)& C,
Handle (Geom2d_Curve)& C2d)
{
if (!theCurve2d.IsNull() || theSurface.IsNull()) {
if (!C2d.IsNull()) {
return;
}
//
Standard_Real umin,umax,vmin,vmax;
//
S->Bounds(umin, umax, vmin, vmax);
// in class ProjLib_Function the range of parameters is shrank by 1.e-09
if ((theLast - theFirst) > 2.e-09) {
theCurve2d = GeomProjLib::Curve2d(theCurve, theFirst, theLast, theSurface, theUmin, theUmax, theVmin, theVmax, theTol);
if (theCurve2d.IsNull()) {
if((l - f) > 2.e-09) {
C2d = GeomProjLib::Curve2d(C,f,l,S,umin,umax,vmin,vmax,Tol);
if (C2d.IsNull()) {
// proj. a circle that goes through the pole on a sphere to the sphere
theTol += Precision::Confusion();
theCurve2d = GeomProjLib::Curve2d(theCurve, theFirst, theLast, theSurface, theTol);
Tol += Precision::Confusion();
C2d = GeomProjLib::Curve2d(C,f,l,S,Tol);
}
const Handle(Standard_Type)& aType = theCurve2d->DynamicType();
if (aType == STANDARD_TYPE(Geom2d_BSplineCurve))
{
const Handle(Standard_Type)& aType = C2d->DynamicType();
if ( aType == STANDARD_TYPE(Geom2d_BSplineCurve))
{
//Check first, last knots to avoid problems with trimming
//First, last knots can differ from f, l because of numerical error
//of projection and approximation
//The same checking as in Geom2d_TrimmedCurve
if ((theCurve2d->FirstParameter() - theFirst > Precision::PConfusion()) ||
(theLast - theCurve2d->LastParameter() > Precision::PConfusion()))
if((C2d->FirstParameter() - f > Precision::PConfusion()) ||
(l - C2d->LastParameter() > Precision::PConfusion()))
{
Handle(Geom2d_BSplineCurve) aBspl = Handle(Geom2d_BSplineCurve)::DownCast(theCurve2d);
Handle(Geom2d_BSplineCurve) aBspl = Handle(Geom2d_BSplineCurve)::DownCast(C2d);
TColStd_Array1OfReal aKnots(1, aBspl->NbKnots());
aBspl->Knots(aKnots);
BSplCLib::Reparametrize(theFirst, theLast, aKnots);
BSplCLib::Reparametrize(f, l, aKnots);
aBspl->SetKnots(aKnots);
}
}
}
else {
if ((theLast - theFirst) > Epsilon(Abs(theFirst)))
if((l - f) > Epsilon(Abs(f)))
{
//The domain of C2d is [Epsilon(Abs(f)), 2.e-09]
//On this small range C2d can be considered as segment
//of line.
Standard_Real aU = 0., aV = 0.;
Standard_Real aU=0., aV=0.;
GeomAdaptor_Surface anAS;
anAS.Load(theSurface);
anAS.Load(S);
Extrema_ExtPS anExtr;
const gp_Pnt aP3d1 = theCurve->Value(theFirst);
const gp_Pnt aP3d2 = theCurve->Value(theLast);
const gp_Pnt aP3d1 = C->Value(f);
const gp_Pnt aP3d2 = C->Value(l);
anExtr.SetAlgo(Extrema_ExtAlgo_Grad);
anExtr.Initialize(anAS, theUmin, theUmax, theVmin, theVmax,
Precision::Confusion(), Precision::Confusion());
anExtr.Initialize(anAS, umin, umax, vmin, vmax,
Precision::Confusion(), Precision::Confusion());
anExtr.Perform(aP3d1);
if (ParametersOfNearestPointOnSurface(anExtr, aU, aV))
if(ParametersOfNearestPointOnSurface(anExtr, aU, aV))
{
const gp_Pnt2d aP2d1(aU, aV);
anExtr.Perform(aP3d2);
if (ParametersOfNearestPointOnSurface(anExtr, aU, aV))
if(ParametersOfNearestPointOnSurface(anExtr, aU, aV))
{
const gp_Pnt2d aP2d2(aU, aV);
if (aP2d1.Distance(aP2d2) > gp::Resolution())
if(aP2d1.Distance(aP2d2) > gp::Resolution())
{
TColgp_Array1OfPnt2d poles(1, 2);
TColStd_Array1OfReal knots(1, 2);
TColStd_Array1OfInteger mults(1, 2);
TColgp_Array1OfPnt2d poles(1,2);
TColStd_Array1OfReal knots(1,2);
TColStd_Array1OfInteger mults(1,2);
poles(1) = aP2d1;
poles(2) = aP2d2;
knots(1) = theFirst;
knots(2) = theLast;
knots(1) = f;
knots(2) = l;
mults(1) = mults(2) = 2;
theCurve2d = new Geom2d_BSplineCurve(poles, knots, mults, 1);
C2d = new Geom2d_BSplineCurve(poles,knots,mults,1);
//Check same parameter in middle point .begin
const gp_Pnt PMid(theCurve->Value(0.5*(theFirst + theLast)));
const gp_Pnt PMid(C->Value(0.5*(f+l)));
const gp_Pnt2d pmidcurve2d(0.5*(aP2d1.XY() + aP2d2.XY()));
const gp_Pnt aPC(anAS.Value(pmidcurve2d.X(), pmidcurve2d.Y()));
const Standard_Real aDist = PMid.Distance(aPC);
theTol = Max(aDist, theTol);
Tol = Max(aDist, Tol);
//Check same parameter in middle point .end
}
}
@@ -1167,51 +1169,27 @@ void GeomInt_IntSS::BuildPCurves (const Standard_Real theFirst, const Standard_R
}
}
//
if (theSurface->IsUPeriodic() && !theCurve2d.IsNull()) {
if (S->IsUPeriodic() && !C2d.IsNull()) {
// Recadre dans le domaine UV de la face
Standard_Real aTm, U0, aEps, period, du, U0x;
Standard_Boolean bAdjust;
//
aEps = Precision::PConfusion();
period = theSurface->UPeriod();
period = S->UPeriod();
//
aTm = .5 * (theFirst + theLast);
gp_Pnt2d pm = theCurve2d->Value(aTm);
aTm = .5*(f + l);
gp_Pnt2d pm = C2d->Value(aTm);
U0 = pm.X();
//
bAdjust =
GeomInt::AdjustPeriodic(U0, theUmin, theUmax, period, U0x, du, aEps);
bAdjust =
GeomInt::AdjustPeriodic(U0, umin, umax, period, U0x, du, aEps);
if (bAdjust) {
gp_Vec2d T1(du, 0.);
theCurve2d->Translate(T1);
C2d->Translate(T1);
}
}
}
//=======================================================================
//function : BuildPCurves
//purpose :
//=======================================================================
void GeomInt_IntSS::BuildPCurves (const Standard_Real f,
const Standard_Real l,
Standard_Real& Tol,
const Handle (Geom_Surface)& S,
const Handle (Geom_Curve)& C,
Handle (Geom2d_Curve)& C2d)
{
if (!C2d.IsNull() || S.IsNull()) {
return;
}
//
Standard_Real umin,umax,vmin,vmax;
//
S->Bounds(umin, umax, vmin, vmax);
BuildPCurves(f, l, umin, umax, vmin, vmax, Tol, S, C, C2d);
}
//=======================================================================
//function : TrimILineOnSurfBoundaries
//purpose : This function finds intersection points of given curves with

View File

@@ -13,217 +13,19 @@
#include <IGESCAFControl_Provider.hxx>
#include <BinXCAFDrivers.hxx>
#include <IGESCAFControl_ConfigurationNode.hxx>
#include <IGESCAFControl_Reader.hxx>
#include <IGESCAFControl_Writer.hxx>
#include <IGESControl_Controller.hxx>
#include <IGESData.hxx>
#include <IGESData_IGESModel.hxx>
#include <Interface_Static.hxx>
#include <Message.hxx>
#include <UnitsMethods.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
IMPLEMENT_STANDARD_RTTIEXT(IGESCAFControl_Provider, DE_Provider)
namespace
{
//! Special class to handle static parameters.
//! Initialize all parameters in the begin of life
//! and reset changed parameters in the end of life
class IGESCAFControl_ParameterController
{
public:
IGESCAFControl_ParameterController(const Handle(IGESCAFControl_ConfigurationNode)& theNode,
const Standard_Boolean theUpdateStatic);
~IGESCAFControl_ParameterController();
protected:
void setStatic(const IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection theParameter);
private:
bool myToUpdateStaticParameters; //!< Flag to updating static parameters
IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection myOldValues; //!< Container to save previous static parameters
IGESCAFControl_ConfigurationNode::DE_SectionGlobal myOldGlobalValues; //!< Container to save previous global parameters
};
//=======================================================================
// function : IGESCAFControl_ParameterController
// purpose :
//=======================================================================
IGESCAFControl_ParameterController::IGESCAFControl_ParameterController(const Handle(IGESCAFControl_ConfigurationNode)& theNode,
const Standard_Boolean theUpdateStatic)
: myToUpdateStaticParameters(theUpdateStatic)
{
IGESControl_Controller::Init();
IGESData::Init();
if (!myToUpdateStaticParameters)
{
return;
}
// Get previous values
myOldValues.ReadBSplineContinuity =
(IGESCAFControl_ConfigurationNode::ReadMode_BSplineContinuity)
Interface_Static::IVal("read.iges.bspline.continuity");
myOldValues.ReadPrecisionMode =
(IGESCAFControl_ConfigurationNode::ReadMode_Precision)
Interface_Static::IVal("read.precision.mode");
myOldValues.ReadPrecisionVal =
Interface_Static::RVal("read.precision.val");
myOldValues.ReadMaxPrecisionMode =
(IGESCAFControl_ConfigurationNode::ReadMode_MaxPrecision)
Interface_Static::IVal("read.maxprecision.mode");
myOldValues.ReadMaxPrecisionVal =
Interface_Static::RVal("read.maxprecision.val");
myOldValues.ReadSameParamMode =
Interface_Static::IVal("read.stdsameparameter.mode") == 1;
myOldValues.ReadSurfaceCurveMode =
(IGESCAFControl_ConfigurationNode::ReadMode_SurfaceCurve)
Interface_Static::IVal("read.surfacecurve.mode");
myOldValues.EncodeRegAngle =
Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
myOldValues.ReadApproxd1 =
Interface_Static::IVal("read.iges.bspline.approxd1.mode") == 1;
myOldValues.ReadResourceName =
Interface_Static::CVal("read.iges.resource.name");
myOldValues.ReadSequence =
Interface_Static::CVal("read.iges.sequence");
myOldValues.ReadFaultyEntities =
Interface_Static::IVal("read.iges.faulty.entities") == 1;
myOldValues.ReadOnlyVisible =
Interface_Static::IVal("read.iges.onlyvisible") == 1;
myOldValues.WriteBRepMode =
(IGESCAFControl_ConfigurationNode::WriteMode_BRep)
Interface_Static::IVal("write.iges.brep.mode");
myOldValues.WriteConvertSurfaceMode =
(IGESCAFControl_ConfigurationNode::WriteMode_ConvertSurface)
Interface_Static::IVal("write.convertsurface.mode");
myOldValues.WriteUnit =
(UnitsMethods_LengthUnit)
Interface_Static::IVal("write.iges.unit");
myOldValues.WriteHeaderAuthor =
Interface_Static::CVal("write.iges.header.author");
myOldValues.WriteHeaderCompany =
Interface_Static::CVal("write.iges.header.company");
myOldValues.WriteHeaderProduct =
Interface_Static::CVal("write.iges.header.product");
myOldValues.WriteHeaderReciever =
Interface_Static::CVal("write.iges.header.receiver");
myOldValues.WriteResourceName =
Interface_Static::CVal("write.iges.resource.name");
myOldValues.WriteSequence =
Interface_Static::CVal("write.iges.sequence");
myOldValues.WritePrecisionMode =
(IGESCAFControl_ConfigurationNode::WriteMode_PrecisionMode)
Interface_Static::IVal("write.precision.mode");
myOldValues.WritePrecisionVal =
Interface_Static::RVal("write.precision.val");
myOldValues.WritePlaneMode =
(IGESCAFControl_ConfigurationNode::WriteMode_PlaneMode)
Interface_Static::IVal("write.iges.plane.mode");
myOldValues.WriteOffsetMode =
Interface_Static::IVal("write.iges.offset.mode") == 1;
myOldGlobalValues.LengthUnit = 0.001 *
UnitsMethods::GetLengthFactorValue(Interface_Static::IVal("xstep.cascade.unit"));
// Set new values
TCollection_AsciiString aStrUnit(
UnitsMethods::DumpLengthUnit(theNode->GlobalParameters.LengthUnit));
aStrUnit.UpperCase();
Interface_Static::SetCVal("xstep.cascade.unit", aStrUnit.ToCString());
UnitsMethods::SetCasCadeLengthUnit(theNode->GlobalParameters.LengthUnit);
setStatic(theNode->InternalParameters);
}
//=======================================================================
// function : ~IGESCAFControl_ParameterController
// purpose :
//=======================================================================
IGESCAFControl_ParameterController::~IGESCAFControl_ParameterController()
{
if (!myToUpdateStaticParameters)
{
return;
}
// Set new values
TCollection_AsciiString aStrUnit(
UnitsMethods::DumpLengthUnit(myOldGlobalValues.LengthUnit,
UnitsMethods_LengthUnit_Meter));
aStrUnit.UpperCase();
Interface_Static::SetCVal("xstep.cascade.unit", aStrUnit.ToCString());
setStatic(myOldValues);
}
//=======================================================================
// function : setStatic
// purpose :
//=======================================================================
void IGESCAFControl_ParameterController::setStatic(const IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection theParameter)
{
Interface_Static::SetIVal("read.iges.bspline.continuity",
theParameter.ReadBSplineContinuity);
Interface_Static::SetIVal("read.precision.mode",
theParameter.ReadPrecisionMode);
Interface_Static::SetRVal("read.precision.val",
theParameter.ReadPrecisionVal);
Interface_Static::SetIVal("read.maxprecision.mode",
theParameter.ReadMaxPrecisionMode);
Interface_Static::SetRVal("read.maxprecision.val",
theParameter.ReadMaxPrecisionVal);
Interface_Static::SetIVal("read.stdsameparameter.mode",
theParameter.ReadSameParamMode);
Interface_Static::SetIVal("read.surfacecurve.mode",
theParameter.ReadSurfaceCurveMode);
Interface_Static::SetRVal("read.encoderegularity.angle",
theParameter.EncodeRegAngle * M_PI / 180.0);
Interface_Static::SetIVal("read.iges.bspline.approxd1.mode",
theParameter.ReadApproxd1);
Interface_Static::SetCVal("read.iges.resource.name",
theParameter.ReadResourceName.ToCString());
Interface_Static::SetCVal("read.iges.sequence",
theParameter.ReadSequence.ToCString());
Interface_Static::SetIVal("read.iges.faulty.entities",
theParameter.ReadFaultyEntities);
Interface_Static::SetIVal("read.iges.onlyvisible",
theParameter.ReadOnlyVisible);
Interface_Static::SetIVal("write.iges.brep.mode",
theParameter.WriteBRepMode);
Interface_Static::SetIVal("write.convertsurface.mode",
theParameter.WriteConvertSurfaceMode);
Interface_Static::SetIVal("write.iges.unit",
theParameter.WriteUnit);
Interface_Static::SetCVal("write.iges.header.author",
theParameter.WriteHeaderAuthor.ToCString());
Interface_Static::SetCVal("write.iges.header.company",
theParameter.WriteHeaderCompany.ToCString());
Interface_Static::SetCVal("write.iges.header.product",
theParameter.WriteHeaderProduct.ToCString());
Interface_Static::SetCVal("write.iges.header.receiver",
theParameter.WriteHeaderReciever.ToCString());
Interface_Static::SetCVal("write.iges.resource.name",
theParameter.WriteResourceName.ToCString());
Interface_Static::SetCVal("write.iges.sequence",
theParameter.WriteSequence.ToCString());
Interface_Static::SetIVal("write.precision.mode",
theParameter.WritePrecisionMode);
Interface_Static::SetRVal("write.precision.val",
theParameter.WritePrecisionVal);
Interface_Static::SetIVal("write.iges.plane.mode",
theParameter.WritePlaneMode);
Interface_Static::SetIVal("write.iges.offset.mode",
theParameter.WriteOffsetMode);
}
}
//=======================================================================
// function : IGESCAFControl_Provider
// purpose :
@@ -240,23 +42,99 @@ IGESCAFControl_Provider::IGESCAFControl_Provider(const Handle(DE_ConfigurationNo
{}
//=======================================================================
// function : STEPCAFControl_Provider
// function : initStatic
// purpose :
//=======================================================================
void IGESCAFControl_Provider::personizeWS(Handle(XSControl_WorkSession)& theWS)
void IGESCAFControl_Provider::initStatic(const Handle(DE_ConfigurationNode)& theNode)
{
if (theWS.IsNull())
{
Message::SendWarning() << "Warning: IGESCAFControl_Provider :"
<< " Null work session, use internal temporary session";
theWS = new XSControl_WorkSession();
}
Handle(IGESControl_Controller) aCntrl =
Handle(IGESControl_Controller)::DownCast(theWS->NormAdaptor());
if (aCntrl.IsNull())
{
theWS->SelectNorm("IGES");
}
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(theNode);
IGESData::Init();
// Get previous values
myOldValues.ReadBSplineContinuity = (IGESCAFControl_ConfigurationNode::ReadMode_BSplineContinuity)Interface_Static::IVal("read.iges.bspline.continuity");
myOldValues.ReadPrecisionMode = (IGESCAFControl_ConfigurationNode::ReadMode_Precision)Interface_Static::IVal("read.precision.mode");
myOldValues.ReadPrecisionVal = Interface_Static::RVal("read.precision.val");
myOldValues.ReadMaxPrecisionMode = (IGESCAFControl_ConfigurationNode::ReadMode_MaxPrecision)Interface_Static::IVal("read.maxprecision.mode");
myOldValues.ReadMaxPrecisionVal = Interface_Static::RVal("read.maxprecision.val");
myOldValues.ReadSameParamMode = Interface_Static::IVal("read.stdsameparameter.mode") == 1;
myOldValues.ReadSurfaceCurveMode = (IGESCAFControl_ConfigurationNode::ReadMode_SurfaceCurve)Interface_Static::IVal("read.surfacecurve.mode");
myOldValues.EncodeRegAngle = Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
myOldValues.ReadApproxd1 = Interface_Static::IVal("read.iges.bspline.approxd1.mode") == 1;
myOldValues.ReadResourceName = Interface_Static::CVal("read.iges.resource.name");
myOldValues.ReadSequence = Interface_Static::CVal("read.iges.sequence");
myOldValues.ReadFaultyEntities = Interface_Static::IVal("read.iges.faulty.entities") == 1;
myOldValues.ReadOnlyVisible = Interface_Static::IVal("read.iges.onlyvisible") == 1;
myOldValues.WriteBRepMode = (IGESCAFControl_ConfigurationNode::WriteMode_BRep)Interface_Static::IVal("write.iges.brep.mode");
myOldValues.WriteConvertSurfaceMode = (IGESCAFControl_ConfigurationNode::WriteMode_ConvertSurface)Interface_Static::IVal("write.convertsurface.mode");
myOldValues.WriteUnit = (UnitsMethods_LengthUnit)Interface_Static::IVal("write.iges.unit");
myOldValues.WriteHeaderAuthor = Interface_Static::CVal("write.iges.header.author");
myOldValues.WriteHeaderCompany = Interface_Static::CVal("write.iges.header.company");
myOldValues.WriteHeaderProduct = Interface_Static::CVal("write.iges.header.product");
myOldValues.WriteHeaderReciever = Interface_Static::CVal("write.iges.header.receiver");
myOldValues.WriteResourceName = Interface_Static::CVal("write.iges.resource.name");
myOldValues.WriteSequence = Interface_Static::CVal("write.iges.sequence");
myOldValues.WritePrecisionMode = (IGESCAFControl_ConfigurationNode::WriteMode_PrecisionMode)Interface_Static::IVal("write.precision.mode");
myOldValues.WritePrecisionVal = Interface_Static::RVal("write.precision.val");
myOldValues.WritePlaneMode = (IGESCAFControl_ConfigurationNode::WriteMode_PlaneMode)Interface_Static::IVal("write.iges.plane.mode");
myOldValues.WriteOffsetMode = Interface_Static::IVal("write.iges.offset.mode") == 1;
myOldLengthUnit = Interface_Static::IVal("xstep.cascade.unit");
// Set new values
UnitsMethods::SetCasCadeLengthUnit(aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
TCollection_AsciiString aStrUnit(UnitsMethods::DumpLengthUnit(aNode->GlobalParameters.LengthUnit));
aStrUnit.UpperCase();
Interface_Static::SetCVal("xstep.cascade.unit", aStrUnit.ToCString());
setStatic(aNode->InternalParameters);
}
//=======================================================================
// function : setStatic
// purpose :
//=======================================================================
void IGESCAFControl_Provider::setStatic(const IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection theParameter)
{
Interface_Static::SetIVal("read.iges.bspline.continuity", theParameter.ReadBSplineContinuity);
Interface_Static::SetIVal("read.precision.mode", theParameter.ReadPrecisionMode);
Interface_Static::SetRVal("read.precision.val", theParameter.ReadPrecisionVal);
Interface_Static::SetIVal("read.maxprecision.mode", theParameter.ReadMaxPrecisionMode);
Interface_Static::SetRVal("read.maxprecision.val", theParameter.ReadMaxPrecisionVal);
Interface_Static::SetIVal("read.stdsameparameter.mode", theParameter.ReadSameParamMode);
Interface_Static::SetIVal("read.surfacecurve.mode", theParameter.ReadSurfaceCurveMode);
Interface_Static::SetRVal("read.encoderegularity.angle", theParameter.EncodeRegAngle * M_PI / 180.0);
Interface_Static::SetIVal("read.iges.bspline.approxd1.mode", theParameter.ReadApproxd1);
Interface_Static::SetCVal("read.iges.resource.name", theParameter.ReadResourceName.ToCString());
Interface_Static::SetCVal("read.iges.sequence", theParameter.ReadSequence.ToCString());
Interface_Static::SetIVal("read.iges.faulty.entities", theParameter.ReadFaultyEntities);
Interface_Static::SetIVal("read.iges.onlyvisible", theParameter.ReadOnlyVisible);
Interface_Static::SetIVal("write.iges.brep.mode", theParameter.WriteBRepMode);
Interface_Static::SetIVal("write.convertsurface.mode", theParameter.WriteConvertSurfaceMode);
Interface_Static::SetIVal("write.iges.unit", theParameter.WriteUnit);
Interface_Static::SetCVal("write.iges.header.author", theParameter.WriteHeaderAuthor.ToCString());
Interface_Static::SetCVal("write.iges.header.company", theParameter.WriteHeaderCompany.ToCString());
Interface_Static::SetCVal("write.iges.header.product", theParameter.WriteHeaderProduct.ToCString());
Interface_Static::SetCVal("write.iges.header.receiver", theParameter.WriteHeaderReciever.ToCString());
Interface_Static::SetCVal("write.iges.resource.name", theParameter.WriteResourceName.ToCString());
Interface_Static::SetCVal("write.iges.sequence", theParameter.WriteSequence.ToCString());
Interface_Static::SetIVal("write.precision.mode", theParameter.WritePrecisionMode);
Interface_Static::SetRVal("write.precision.val", theParameter.WritePrecisionVal);
Interface_Static::SetIVal("write.iges.plane.mode", theParameter.WritePlaneMode);
Interface_Static::SetIVal("write.iges.offset.mode", theParameter.WriteOffsetMode);
}
//=======================================================================
// function : resetStatic
// purpose :
//=======================================================================
void IGESCAFControl_Provider::resetStatic()
{
Interface_Static::SetIVal("xstep.cascade.unit", myOldLengthUnit);
UnitsMethods::SetCasCadeLengthUnit(myOldLengthUnit);
setStatic(myOldValues);
}
//=======================================================================
@@ -270,70 +148,50 @@ bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
{
if (theDocument.IsNull())
{
Message::SendFail() << "Error: IGESCAFControl_Provider : "
<< "Null document";
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
return false;
}
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: IGESCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(IGESCAFControl_ConfigurationNode) aNode =
Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
IGESCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
aNode->GlobalParameters.LengthUnit,
UnitsMethods_LengthUnit_Millimeter);
const Standard_Boolean toUseLoaded = thePath == ".";
TCollection_AsciiString aFile;
if (toUseLoaded)
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
IGESCAFControl_Reader aReader;
if (!theWS.IsNull())
{
aFile = theWS->LoadedFile();
Message::SendInfo() << "Model taken from the IGES session : "
<< aFile;
aReader.SetWS(theWS);
}
else
{
aFile = thePath;
Message::SendInfo() << "File IGES to read : "
<< aFile;
}
IGESCAFControl_Reader aReader(theWS, !toUseLoaded);
aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
aReader.SetColorMode(aNode->InternalParameters.ReadColor);
aReader.SetNameMode(aNode->InternalParameters.ReadName);
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
Handle(IGESData_IGESModel) aModel = aReader.IGESModel();
if (aModel.IsNull())
{
aModel = Handle(IGESData_IGESModel)::DownCast(theWS->NewModel());
}
aModel->ClearHeader();
aModel->ChangeGlobalSection().SetCascadeUnit(aNode->GlobalParameters.LengthUnit);
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
if (!toUseLoaded)
{
aReadStat = aReader.ReadFile(thePath.ToCString());
}
else if (theWS->NbStartingEntities() > 0)
{
aReadStat = IFSelect_RetDone;
}
aReadStat = aReader.ReadFile(thePath.ToCString());
if (aReadStat != IFSelect_RetDone)
{
Message::SendFail() << "Error: IGESCAFControl_Provider : ["
<< aFile << "] : abandon, no model loaded";
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: abandon, no model loaded";
resetStatic();
return false;
}
if (!aReader.Transfer(theDocument, theProgress))
{
Message::SendFail() << "Error: IGESCAFControl_Provider : [" <<
aFile << "] : Cannot read any relevant data from the IGES file";
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Cannot read any relevant data from the IGES file";
resetStatic();
return false;
}
resetStatic();
return true;
}
@@ -348,35 +206,18 @@ bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
{
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: IGESCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(IGESCAFControl_ConfigurationNode) aNode =
Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
IGESCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
TCollection_AsciiString aUnit(
UnitsMethods::DumpLengthUnit(aNode->InternalParameters.WriteUnit));
aUnit.UpperCase();
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
IGESCAFControl_Writer aWriter(theWS, Standard_True);
if (aNode->InternalParameters.WriteUnit > UnitsMethods_LengthUnit_Undefined &&
aNode->InternalParameters.WriteUnit <= UnitsMethods_LengthUnit_Microinch)
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter);
IGESCAFControl_Writer aWriter;
if (!theWS.IsNull())
{
Handle(IGESData_IGESModel) aModel = aWriter.Model();
IGESData_GlobalSection aGSesction = aModel->GlobalSection();
Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(
IGESData_BasicEditor::UnitFlagName(aNode->InternalParameters.WriteUnit));
if (aGSesction.UnitFlag() == 3)
{
aGSesction.SetUnitName(aName);
}
else if (aGSesction.UnitFlag() > 0)
{
aGSesction.SetUnitFlag(aNode->InternalParameters.WriteUnit);
}
aModel->SetGlobalSection(aGSesction);
aWriter = IGESCAFControl_Writer(theWS);
}
aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
aWriter.SetNameMode(aNode->InternalParameters.WriteName);
@@ -384,25 +225,46 @@ bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
if (!aWriter.Transfer(theDocument, theProgress))
{
Message::SendFail() << "Error: IGESCAFControl_Provider : "
<< "The document cannot be translated or gives no result";
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: The document cannot be translated or gives no result";
resetStatic();
return false;
}
if (thePath == ".")
{
Message::SendInfo() << "Document has been translated into the session";
return true;
}
if (!aWriter.Write(thePath.ToCString()))
{
Message::SendFail() << "Error: IGESCAFControl_Provider : [" <<
thePath << "] : Write failed";
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Write failed";
resetStatic();
return false;
}
Message::SendInfo() << "IGES file [" << thePath << "] Successfully written";
resetStatic();
return true;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
Handle(XSControl_WorkSession) aWS;
return Read(thePath, theDocument, aWS, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
Handle(XSControl_WorkSession) aWS;
return Write(thePath, theDocument, aWS, theProgress);
}
//=======================================================================
// function : Read
// purpose :
@@ -415,39 +277,36 @@ bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
(void)theProgress;
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: IGESCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(IGESCAFControl_ConfigurationNode) aNode =
Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
IGESCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
IGESControl_Reader aReader;
aReader.SetWS(theWS);
Handle(IGESData_IGESModel) aModel = aReader.IGESModel();
if (aModel.IsNull())
if (!theWS.IsNull())
{
aModel = Handle(IGESData_IGESModel)::DownCast(theWS->NewModel());
aReader.SetWS(theWS);
}
aModel->ClearHeader();
aModel->ChangeGlobalSection().SetCascadeUnit(aNode->GlobalParameters.LengthUnit);
aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
aReadStat = aReader.ReadFile(thePath.ToCString());
if (aReadStat != IFSelect_RetDone)
{
Message::SendFail() << "Error: IGESCAFControl_Provider : [" <<
thePath << "] : Could not read file, no model loaded";
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Could not read file, no model loaded";
resetStatic();
return false;
}
if (aReader.TransferRoots() <= 0)
{
Message::SendFail() << "Error: IGESCAFControl_Provider : [" <<
thePath << "] : Cannot read any relevant data from the IGES file";
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Cannot read any relevant data from the IGES file";
resetStatic();
return false;
}
theShape = aReader.OneShape();
resetStatic();
return true;
}
@@ -464,36 +323,58 @@ bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
(void)theProgress;
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: IGESCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(IGESCAFControl_ConfigurationNode) aNode =
Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
IGESCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
TCollection_AsciiString aUnit(
UnitsMethods::DumpLengthUnit(aNode->InternalParameters.WriteUnit));
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
TCollection_AsciiString aUnit(UnitsMethods::DumpLengthUnit(aNode->InternalParameters.WriteUnit));
aUnit.UpperCase();
IGESControl_Writer aWriter(aUnit.ToCString(),
aNode->InternalParameters.WriteBRepMode);
Standard_Boolean aIsOk = aWriter.AddShape(theShape);
if (!aIsOk)
{
Message::SendFail() << "Error: IGESCAFControl_Provider : "
<< "Can't translate shape to IGES model";
Message::SendFail() << "IGESCAFControl_Provider: Shape not written";
resetStatic();
return false;
}
if (!(aWriter.Write(thePath.ToCString())))
{
Message::SendFail() << "Error: IGESCAFControl_Provider : "
<< "Can't write IGES file" << thePath;
Message::SendFail() << "IGESCAFControl_Provider: Error on writing file " << thePath;
resetStatic();
return false;
}
resetStatic();
return true;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(XSControl_WorkSession) aWS;
return Read(thePath, theShape, aWS, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(XSControl_WorkSession) aWS;
return Write(thePath, theShape, aWS, theProgress);
}
//=======================================================================
// function : GetFormat
// purpose :

View File

@@ -15,7 +15,6 @@
#define _IGESCAFControl_Provider_HeaderFile
#include <DE_Provider.hxx>
#include <DE_ConfigurationNode.hxx>
#include <IGESCAFControl_ConfigurationNode.hxx>
//! The class to transfer IGES files.
@@ -66,6 +65,23 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
@@ -89,6 +105,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
//! Gets CAD format name of associated provider
@@ -99,24 +133,19 @@ public:
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
public:
//! Sets parameter to update static parameter, that true by default
void SetToUpdateStaticParameters(const bool theToUpdate) { myToUpdateStaticParameters = theToUpdate; }
//! Gets parameter to update static parameter, that true by default
bool ToUpdateStaticParameters() const { return myToUpdateStaticParameters; }
private:
//! Personizes work session with current format.
//! Creates new temporary session if current session is null
//! @param[in] theWS current work session
void personizeWS(Handle(XSControl_WorkSession)& theWS);
//! Initialize static variables
void initStatic(const Handle(DE_ConfigurationNode)& theNode);
private:
//! Initialize static variables
void setStatic(const IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection theParameter);
bool myToUpdateStaticParameters = true; //!< Flag to updating static parameters
//! Reset used interface static variables
void resetStatic();
IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection myOldValues;
int myOldLengthUnit = 1;
};

View File

@@ -990,19 +990,15 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
if (typl == IntPatch_Circle || typl == IntPatch_Ellipse) {////
if(myApprox1) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm,
myHS1->FirstUParameter(), myHS1->LastUParameter(),
myHS1->FirstVParameter(), myHS1->LastVParameter(),
Tolpc, myHS1->Surface(), newc, C2d);
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS1->Surface(), newc, C2d);
aCurve.SetFirstCurve2d(C2d);
}
if(myApprox2) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm,
myHS2->FirstUParameter(), myHS2->LastUParameter(),
myHS2->FirstVParameter(), myHS2->LastVParameter(),
Tolpc, myHS2->Surface(), newc, C2d);
GeomInt_IntSS::BuildPCurves(fprm,lprm,Tolpc,
myHS2->Surface(),newc,C2d);
aCurve.SetSecondCurve2d(C2d);
}
}
@@ -1063,19 +1059,15 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
if(myApprox1) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm,
myHS1->FirstUParameter(), myHS1->LastUParameter(),
myHS1->FirstVParameter(), myHS1->LastVParameter(),
Tolpc, myHS1->Surface(), newc, C2d);
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS1->Surface(), newc, C2d);
aCurve.SetFirstCurve2d(C2d);
}
if(myApprox2) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm,
myHS2->FirstUParameter(), myHS2->LastUParameter(),
myHS2->FirstVParameter(), myHS2->LastVParameter(),
Tolpc, myHS2->Surface(), newc, C2d);
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS2->Surface(), newc, C2d);
aCurve.SetSecondCurve2d(C2d);
}
}// end of if (typl == IntPatch_Circle || typl == IntPatch_Ellipse)

View File

@@ -53,43 +53,43 @@ bool RWGltf_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRe
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
InternalParameters.FileLengthUnit =
InternalParameters.FileLengthUnit =
theResource->RealVal("file.length.unit", InternalParameters.FileLengthUnit, aScope);
InternalParameters.SystemCS = (RWMesh_CoordinateSystem)
(theResource->IntegerVal("system.cs", (int)InternalParameters.SystemCS, aScope) % 2);
InternalParameters.FileCS = (RWMesh_CoordinateSystem)
(theResource->IntegerVal("file.cs", (int)InternalParameters.SystemCS, aScope) % 2);
InternalParameters.ReadSinglePrecision =
InternalParameters.ReadSinglePrecision =
theResource->BooleanVal("read.single.precision", InternalParameters.ReadSinglePrecision, aScope);
InternalParameters.ReadCreateShapes =
InternalParameters.ReadCreateShapes =
theResource->BooleanVal("read.create.shapes", InternalParameters.ReadCreateShapes, aScope);
InternalParameters.ReadRootPrefix =
InternalParameters.ReadRootPrefix =
theResource->StringVal("read.root.prefix", InternalParameters.ReadRootPrefix, aScope);
InternalParameters.ReadFillDoc =
InternalParameters.ReadFillDoc =
theResource->BooleanVal("read.fill.doc", InternalParameters.ReadFillDoc, aScope);
InternalParameters.ReadFillIncomplete =
InternalParameters.ReadFillIncomplete =
theResource->BooleanVal("read.fill.incomplete", InternalParameters.ReadFillIncomplete, aScope);
InternalParameters.ReadMemoryLimitMiB =
InternalParameters.ReadMemoryLimitMiB =
theResource->IntegerVal("read.memory.limit.mib", InternalParameters.ReadMemoryLimitMiB, aScope);
InternalParameters.ReadParallel =
InternalParameters.ReadParallel =
theResource->BooleanVal("read.parallel", InternalParameters.ReadParallel, aScope);
InternalParameters.ReadSkipEmptyNodes =
InternalParameters.ReadSkipEmptyNodes =
theResource->BooleanVal("read.skip.empty.nodes", InternalParameters.ReadSkipEmptyNodes, aScope);
InternalParameters.ReadLoadAllScenes =
InternalParameters.ReadLoadAllScenes =
theResource->BooleanVal("read.load.all.scenes", InternalParameters.ReadLoadAllScenes, aScope);
InternalParameters.ReadUseMeshNameAsFallback =
InternalParameters.ReadUseMeshNameAsFallback =
theResource->BooleanVal("read.use.mesh.name.as.fallback", InternalParameters.ReadUseMeshNameAsFallback, aScope);
InternalParameters.ReadSkipLateDataLoading =
InternalParameters.ReadSkipLateDataLoading =
theResource->BooleanVal("read.skip.late.data.loading", InternalParameters.ReadSkipLateDataLoading, aScope);
InternalParameters.ReadKeepLateData =
InternalParameters.ReadKeepLateData =
theResource->BooleanVal("read.keep.late.data", InternalParameters.ReadKeepLateData, aScope);
InternalParameters.ReadPrintDebugMessages =
InternalParameters.ReadPrintDebugMessages =
theResource->BooleanVal("read.print.debug.message", InternalParameters.ReadPrintDebugMessages, aScope);
InternalParameters.WriteComment =
InternalParameters.WriteComment =
theResource->StringVal("write.comment", InternalParameters.WriteComment, aScope);
InternalParameters.WriteAuthor =
InternalParameters.WriteAuthor =
theResource->StringVal("write.author", InternalParameters.WriteAuthor, aScope);
InternalParameters.WriteTrsfFormat = (RWGltf_WriterTrsfFormat)
@@ -98,43 +98,14 @@ bool RWGltf_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRe
(theResource->IntegerVal("write.node.name.format", InternalParameters.WriteNodeNameFormat, aScope) % (RWMesh_NameFormat_ProductAndInstanceAndOcaf + 1));
InternalParameters.WriteMeshNameFormat = (RWMesh_NameFormat)
(theResource->IntegerVal("write.mesh.name.format", InternalParameters.WriteMeshNameFormat, aScope) % (RWMesh_NameFormat_ProductAndInstanceAndOcaf + 1));
// Draco parameters
InternalParameters.WriteDracoParameters.DracoCompression =
theResource->BooleanVal("write.draco.compression",
InternalParameters.WriteDracoParameters.DracoCompression, aScope);
InternalParameters.WriteDracoParameters.CompressionLevel =
theResource->IntegerVal("write.draco.level",
InternalParameters.WriteDracoParameters.CompressionLevel, aScope);
InternalParameters.WriteDracoParameters.QuantizePositionBits =
theResource->IntegerVal("write.draco.position.bits",
InternalParameters.WriteDracoParameters.QuantizePositionBits, aScope);
InternalParameters.WriteDracoParameters.QuantizeNormalBits =
theResource->IntegerVal("write.draco.normal.bits",
InternalParameters.WriteDracoParameters.QuantizeNormalBits, aScope);
InternalParameters.WriteDracoParameters.QuantizeTexcoordBits =
theResource->IntegerVal("write.draco.texture.bits",
InternalParameters.WriteDracoParameters.QuantizeTexcoordBits, aScope);
InternalParameters.WriteDracoParameters.QuantizeColorBits =
theResource->IntegerVal("write.draco.color.bits",
InternalParameters.WriteDracoParameters.QuantizeColorBits, aScope);
InternalParameters.WriteDracoParameters.QuantizeGenericBits =
theResource->IntegerVal("write.draco.generic.bits",
InternalParameters.WriteDracoParameters.QuantizeGenericBits, aScope);
InternalParameters.WriteDracoParameters.UnifiedQuantization =
theResource->BooleanVal("write.draco.unified.quantization",
InternalParameters.WriteDracoParameters.UnifiedQuantization, aScope);
InternalParameters.WriteForcedUVExport =
InternalParameters.WriteForcedUVExport =
theResource->BooleanVal("write.forced.uv.export", InternalParameters.WriteForcedUVExport, aScope);
InternalParameters.WriteEmbedTexturesInGlb =
InternalParameters.WriteEmbedTexturesInGlb =
theResource->BooleanVal("write.embed.textures.in.glb", InternalParameters.WriteEmbedTexturesInGlb, aScope);
InternalParameters.WriteMergeFaces =
InternalParameters.WriteMergeFaces =
theResource->BooleanVal("write.merge.faces", InternalParameters.WriteMergeFaces, aScope);
InternalParameters.WriteSplitIndices16 =
InternalParameters.WriteSplitIndices16 =
theResource->BooleanVal("write.split.indices16", InternalParameters.WriteSplitIndices16, aScope);
InternalParameters.WriteParallel =
theResource->BooleanVal("write.parallel", InternalParameters.WriteParallel, aScope);
return true;
}
@@ -287,63 +258,6 @@ TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
aResult += aScope + "write.mesh.name.format :\t " + InternalParameters.WriteMeshNameFormat + "\n";
aResult += "!\n";
// Draco parameters
aResult += "!\n";
aResult += "!Flag to use Draco compression. If it is TRUE, compression is used\n";
aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
aResult += aScope + "write.draco.compression :\t " +
InternalParameters.WriteDracoParameters.DracoCompression + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Draco compression level\n";
aResult += "!Default value: 7. Available values: [0-10]\n";
aResult += aScope + "write.draco.level :\t " +
InternalParameters.WriteDracoParameters.CompressionLevel + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Quantization bits for position attribute\n";
aResult += "!Default value: 14. Available values: any positive value\n";
aResult += aScope + "write.draco.position.bits :\t " +
InternalParameters.WriteDracoParameters.QuantizePositionBits + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Quantization bits for normal attribute\n";
aResult += "!Default value: 10. Available values: any positive value\n";
aResult += aScope + "write.draco.normal.bits :\t " +
InternalParameters.WriteDracoParameters.QuantizeNormalBits + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Quantization bits for texture coordinate attribute\n";
aResult += "!Default value: 12. Available values: any positive value\n";
aResult += aScope + "write.draco.texture.bits :\t " +
InternalParameters.WriteDracoParameters.QuantizeTexcoordBits + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Quantization bits for color attributes\n";
aResult += "!Default value: 8. Available values: any positive value\n";
aResult += aScope + "write.draco.color.bits :\t " +
InternalParameters.WriteDracoParameters.QuantizeColorBits + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Quantization bits for skinning and custom attributes\n";
aResult += "!Default value: 12. Available values: any positive value\n";
aResult += aScope + "write.draco.generic.bits :\t " +
InternalParameters.WriteDracoParameters.QuantizeGenericBits + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Quantize positions of all primitives using the same quantization grid\n";
aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
aResult += aScope + "write.draco.unified.quantization :\t " +
InternalParameters.WriteDracoParameters.UnifiedQuantization + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Export UV coordinates even if there are no mapped texture\n";
aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
@@ -368,12 +282,6 @@ TCollection_AsciiString RWGltf_ConfigurationNode::Save() const
aResult += aScope + "write.split.indices16 :\t " + InternalParameters.WriteSplitIndices16 + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Flag to use multithreading\n";
aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
aResult += aScope + "write.parallel :\t " + InternalParameters.WriteParallel + "\n";
aResult += "!\n";
aResult += "!*****************************************************************************\n";
return aResult;
}

View File

@@ -16,7 +16,6 @@
#include <DE_ConfigurationNode.hxx>
#include <RWMesh_CoordinateSystem.hxx>
#include <RWGltf_DracoParameters.hxx>
#include <RWGltf_WriterTrsfFormat.hxx>
#include <RWMesh_NameFormat.hxx>
@@ -108,12 +107,10 @@ public:
RWGltf_WriterTrsfFormat WriteTrsfFormat = RWGltf_WriterTrsfFormat_Compact; //!< Transformation format to write into glTF file
RWMesh_NameFormat WriteNodeNameFormat = RWMesh_NameFormat_InstanceOrProduct; //!< Name format for exporting Nodes
RWMesh_NameFormat WriteMeshNameFormat = RWMesh_NameFormat_Product; //!< Name format for exporting Meshes
RWGltf_DracoParameters WriteDracoParameters; //!< Defines draco compression parameters
bool WriteForcedUVExport = false; //!< Export UV coordinates even if there are no mapped texture
bool WriteEmbedTexturesInGlb = true; //!< Flag to write image textures into GLB file
bool WriteMergeFaces = false; //!< Flag to merge faces within a single part
bool WriteSplitIndices16 = false; //!< Flag to prefer keeping 16-bit indexes while merging face
bool WriteParallel = false; //!< Flag to use multithreading
} InternalParameters;
};

View File

@@ -20,14 +20,13 @@
#include <XCAFDoc_ShapeTool.hxx>
#include <XCAFDoc_DocumentTool.hxx>
namespace
namespace
{
//=======================================================================
// function : SetReaderParameters
// purpose :
//=======================================================================
static void SetReaderParameters(RWGltf_CafReader& theReader,
const Handle(RWGltf_ConfigurationNode) theNode)
static void SetReaderParameters(RWGltf_CafReader& theReader, const Handle(RWGltf_ConfigurationNode) theNode)
{
theReader.SetDoublePrecision(!theNode->InternalParameters.ReadSinglePrecision);
theReader.SetSystemLengthUnit(theNode->GlobalParameters.LengthUnit / 1000);
@@ -74,36 +73,7 @@ bool RWGltf_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (theDocument.IsNull())
{
Message::SendFail() << "Error: RWGltf_Provider : "
<< "Null document";
return false;
}
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
{
Message::SendFail() << "Error: RWGltf_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWGltf_ConfigurationNode) aNode =
Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
RWGltf_CafReader aReader;
aReader.SetDocument(theDocument);
SetReaderParameters(aReader, aNode);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
aNode->GlobalParameters.LengthUnit,
UnitsMethods_LengthUnit_Millimeter);
if (!aReader.Perform(thePath, theProgress))
{
Message::SendFail() << "Error: RWGltf_Provider : [" <<
thePath << "] : Cannot read any relevant data from the GLTF file";
return false;
}
myExternalFiles = aReader.ExternalFiles();
myMetadata = aReader.Metadata();
return true;
return Read(thePath, theDocument, theProgress);
}
//=======================================================================
@@ -116,15 +86,58 @@ bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
return Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool RWGltf_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
Message::SendFail() << "Error: RWGltf_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
return false;
}
Handle(RWGltf_ConfigurationNode) aNode =
Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
if (GetNode().IsNull() || (!GetNode().IsNull() && !GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode))))
{
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(RWGltf_ConfigurationNode) aNode = Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
RWGltf_CafReader aReader;
aReader.SetDocument(theDocument);
SetReaderParameters(aReader, aNode);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
if (!aReader.Perform(thePath, theProgress))
{
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " << thePath;
return false;
}
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWGltf_Provider during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(RWGltf_ConfigurationNode) aNode = Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
RWMesh_CoordinateSystemConverter aConverter;
aConverter.SetInputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
@@ -146,19 +159,16 @@ bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
anExt.LowerCase();
RWGltf_CafWriter aWriter(thePath, anExt.EndsWith(".glb"));
aWriter.SetCoordinateSystemConverter(aConverter);
aWriter.SetCompressionParameters(aNode->InternalParameters.WriteDracoParameters);
aWriter.SetTransformationFormat(aNode->InternalParameters.WriteTrsfFormat);
aWriter.SetNodeNameFormat(aNode->InternalParameters.WriteNodeNameFormat);
aWriter.SetMeshNameFormat(aNode->InternalParameters.WriteMeshNameFormat);
aWriter.SetForcedUVExport(aNode->InternalParameters.WriteForcedUVExport);
aWriter.SetToEmbedTexturesInGlb(aNode->InternalParameters.WriteEmbedTexturesInGlb);
aWriter.SetMergeFaces(aNode->InternalParameters.WriteMergeFaces);
aWriter.SetParallel(aNode->InternalParameters.WriteParallel);
aWriter.SetSplitIndices16(aNode->InternalParameters.WriteSplitIndices16);
if (!aWriter.Perform(theDocument, aFileInfo, theProgress))
{
Message::SendFail() << "Error: RWGltf_Provider : [" <<
thePath << "] : Cannot write any relevant data to the GLTF file";
Message::SendFail() << "Error in the RWGltf_Provider during writing the file " << thePath;
return false;
}
return true;
@@ -174,27 +184,7 @@ bool RWGltf_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
{
Message::SendFail() << "Error: RWGltf_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWGltf_ConfigurationNode) aNode =
Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
RWGltf_CafReader aReader;
SetReaderParameters(aReader, aNode);
if (!aReader.Perform(thePath, theProgress))
{
Message::SendFail() << "Error: RWGltf_Provider : [" <<
thePath << "] : Cannot read any relevant data from the GLTF file";
return false;
}
theShape = aReader.SingleShape();
myExternalFiles = aReader.ExternalFiles();
myMetadata = aReader.Metadata();
return true;
return Read(thePath, theShape, theProgress);
}
//=======================================================================
@@ -207,10 +197,47 @@ bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool RWGltf_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWGltf_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(RWGltf_ConfigurationNode) aNode = Handle(RWGltf_ConfigurationNode)::DownCast(GetNode());
RWGltf_CafReader aReader;
SetReaderParameters(aReader, aNode);
if (!aReader.Perform(thePath, theProgress))
{
Message::SendFail() << "Error in the RWGltf_Provider during reading the file " << thePath;
return false;
}
theShape = aReader.SingleShape();
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
return Write(thePath, aDoc, theWS, theProgress);
return Write(thePath, aDoc, theProgress);
}
//=======================================================================

View File

@@ -66,6 +66,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
@@ -88,6 +106,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
//! Gets CAD format name of associated provider
@@ -98,18 +134,6 @@ public:
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
public:
//!
const TColStd_IndexedDataMapOfStringString& GetMetadata() const { return myMetadata; }
//!
const NCollection_IndexedMap<TCollection_AsciiString>& GetExternalFiles() const { return myExternalFiles; }
private:
TColStd_IndexedDataMapOfStringString myMetadata; //!<
NCollection_IndexedMap<TCollection_AsciiString> myExternalFiles; //!<
};
#endif // _RWGltf_Provider_HeaderFile

View File

@@ -63,8 +63,6 @@ bool RWObj_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRes
theResource->BooleanVal("read.single.precision", InternalParameters.ReadSinglePrecision, aScope);
InternalParameters.ReadCreateShapes =
theResource->BooleanVal("read.create.shapes", InternalParameters.ReadCreateShapes, aScope);
InternalParameters.ReadCreateSingle =
theResource->BooleanVal("read.create.single", InternalParameters.ReadCreateSingle, aScope);
InternalParameters.ReadRootPrefix =
theResource->StringVal("read.root.prefix", InternalParameters.ReadRootPrefix, aScope);
InternalParameters.ReadFillDoc =
@@ -125,17 +123,11 @@ TCollection_AsciiString RWObj_ConfigurationNode::Save() const
aResult += "!\n";
aResult += "!\n";
aResult += "!Flag for create shapes in shape reading case\n";
aResult += "!Flag for create a single triangulation\n";
aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
aResult += aScope + "read.create.shapes :\t " + InternalParameters.ReadCreateShapes + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Flag for create shapes in shape reading case\n";
aResult += "!Default value: 0(false). Available values: 0(false), 1(true)\n";
aResult += aScope + "read.create.single :\t " + InternalParameters.ReadCreateSingle + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Root folder for generating root labels names\n";
aResult += "!Default value: ""(empty). Available values: <path>\n";

View File

@@ -87,8 +87,7 @@ public:
RWMesh_CoordinateSystem FileCS = RWMesh_CoordinateSystem_Yup; //!< File origin coordinate system to perform conversion during read
// Reading
bool ReadSinglePrecision = false; //!< Flag for reading vertex data with single or double floating point precision
bool ReadCreateShapes = false; //!< Flag for create shapes in shape reading case
bool ReadCreateSingle = false; //!< Flag for create a single triangulation in shape reading case
bool ReadCreateShapes = false; //!< Flag for create a single triangulation
TCollection_AsciiString ReadRootPrefix; //!< Root folder for generating root labels names
bool ReadFillDoc = true; //!< Flag for fill document from shape sequence
bool ReadFillIncomplete = true; //!< Flag for fill the document with partially retrieved data even if reader has failed with error

View File

@@ -49,38 +49,7 @@ bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (theDocument.IsNull())
{
Message::SendFail() << "Error: RWObj_Provider : "
<< "Null document";
return false;
}
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
{
Message::SendFail() << "Error: RWObj_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWObj_ConfigurationNode) aNode =
Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
RWObj_CafReader aReader;
aReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
aReader.SetSystemLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
aReader.SetSystemCoordinateSystem(aNode->InternalParameters.SystemCS);
aReader.SetFileLengthUnit(aNode->InternalParameters.FileLengthUnit);
aReader.SetFileCoordinateSystem(aNode->InternalParameters.FileCS);
aReader.SetDocument(theDocument);
aReader.SetRootPrefix(aNode->InternalParameters.ReadRootPrefix);
aReader.SetMemoryLimitMiB(aNode->InternalParameters.ReadMemoryLimitMiB);
if (!aReader.Perform(thePath, theProgress))
{
Message::SendFail() << "Error: RWObj_Provider : [" <<
thePath << "] : Cannot read any relevant data from the Obj file";
return false;
}
myExternalFiles = aReader.ExternalFiles();
return true;
return Read(thePath, theDocument, theProgress);
}
//=======================================================================
@@ -93,15 +62,63 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
return Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
Message::SendFail() << "Error: RWObj_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the RWObj_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
return false;
}
Handle(RWObj_ConfigurationNode) aNode =
Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
RWObj_CafReader aReader;
aReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
aReader.SetSystemLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
aReader.SetSystemCoordinateSystem(aNode->InternalParameters.SystemCS);
aReader.SetFileLengthUnit(aNode->InternalParameters.FileLengthUnit);
aReader.SetFileCoordinateSystem(aNode->InternalParameters.FileCS);
aReader.SetDocument(theDocument);
aReader.SetRootPrefix(aNode->InternalParameters.ReadRootPrefix);
aReader.SetMemoryLimitMiB(aNode->InternalParameters.ReadMemoryLimitMiB);
if (!aReader.Perform(thePath, theProgress))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " << thePath;
return false;
}
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
TColStd_IndexedDataMapOfStringString aFileInfo;
if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
@@ -112,6 +129,7 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
{
aFileInfo.Add("Comments", aNode->InternalParameters.WriteComment);
}
RWMesh_CoordinateSystemConverter aConverter;
aConverter.SetInputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
aConverter.SetInputCoordinateSystem(aNode->InternalParameters.SystemCS);
@@ -122,8 +140,7 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
aWriter.SetCoordinateSystemConverter(aConverter);
if (!aWriter.Perform(theDocument, aFileInfo, theProgress))
{
Message::SendFail() << "Error: RWObj_Provider : [" <<
thePath << "] : Cannot write any relevant data to the Obj file";
Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " << thePath;
return false;
}
return true;
@@ -139,61 +156,7 @@ bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
{
Message::SendFail() << "Error: RWObj_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWObj_ConfigurationNode) aNode =
Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
if (aNode->InternalParameters.ReadCreateSingle)
{
RWMesh_CoordinateSystemConverter aConverter;
aConverter.SetOutputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.SystemCS);
aConverter.SetInputLengthUnit(aNode->InternalParameters.FileLengthUnit);
aConverter.SetInputCoordinateSystem(aNode->InternalParameters.FileCS);
RWObj_TriangulationReader aSimpleReader;
aSimpleReader.SetTransformation(aConverter);
aSimpleReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
aSimpleReader.SetCreateShapes(aNode->InternalParameters.ReadCreateShapes);
aSimpleReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
aSimpleReader.SetMemoryLimit(aNode->InternalParameters.ReadMemoryLimitMiB);
if (!aSimpleReader.Read(thePath, theProgress))
{
Message::SendFail() << "Error: RWObj_Provider : [" <<
thePath << "] : Cannot read any relevant data from the Obj file";
return false;
}
Handle(Poly_Triangulation) aTriangulation = aSimpleReader.GetTriangulation();
TopoDS_Face aFace;
BRep_Builder aBuiler;
aBuiler.MakeFace(aFace);
aBuiler.UpdateFace(aFace, aTriangulation);
theShape = aFace;
myExternalFiles = aSimpleReader.ExternalFiles();
return true;
}
RWObj_CafReader aReader;
aReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
aReader.SetSystemLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
aReader.SetSystemCoordinateSystem(aNode->InternalParameters.SystemCS);
aReader.SetFileLengthUnit(aNode->InternalParameters.FileLengthUnit);
aReader.SetFileCoordinateSystem(aNode->InternalParameters.FileCS);
aReader.SetRootPrefix(aNode->InternalParameters.ReadRootPrefix);
aReader.SetMemoryLimitMiB(aNode->InternalParameters.ReadMemoryLimitMiB);
if (!aReader.Perform(thePath, theProgress))
{
Message::SendFail() << "Error: RWObj_Provider : [" <<
thePath << "] : Cannot read any relevant data from the Obj file";
return false;
}
theShape = aReader.SingleShape();
myExternalFiles = aReader.ExternalFiles();
return true;
return Read(thePath, theShape, theProgress);
}
//=======================================================================
@@ -206,11 +169,62 @@ bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool RWObj_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWObj_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(RWObj_ConfigurationNode) aNode = Handle(RWObj_ConfigurationNode)::DownCast(GetNode());
RWMesh_CoordinateSystemConverter aConverter;
aConverter.SetOutputLengthUnit(aNode->GlobalParameters.LengthUnit / 1000);
aConverter.SetOutputCoordinateSystem(aNode->InternalParameters.SystemCS);
aConverter.SetInputLengthUnit(aNode->InternalParameters.FileLengthUnit);
aConverter.SetInputCoordinateSystem(aNode->InternalParameters.FileCS);
RWObj_TriangulationReader aSimpleReader;
aSimpleReader.SetTransformation(aConverter);
aSimpleReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
aSimpleReader.SetCreateShapes(aNode->InternalParameters.ReadCreateShapes);
aSimpleReader.SetSinglePrecision(aNode->InternalParameters.ReadSinglePrecision);
aSimpleReader.SetMemoryLimit(aNode->InternalParameters.ReadMemoryLimitMiB);
if (!aSimpleReader.Read(thePath, theProgress))
{
Message::SendFail() << "Error in the RWObj_ConfigurationNode during reading the file " << thePath;
return false;
}
Handle(Poly_Triangulation) aTriangulation = aSimpleReader.GetTriangulation();
TopoDS_Face aFace;
BRep_Builder aBuiler;
aBuiler.MakeFace(aFace);
aBuiler.UpdateFace(aFace, aTriangulation);
theShape = aFace;
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool RWObj_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool =
XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
return Write(thePath, aDoc, theWS, theProgress);
return Write(thePath, aDoc, theProgress);
}
//=======================================================================

View File

@@ -16,8 +16,6 @@
#include <DE_Provider.hxx>
#include <NCollection_IndexedMap.hxx>
//! The class to transfer OBJ files.
//! Reads and Writes any OBJ files into/from OCCT.
//! Each operation needs configuration node.
@@ -66,6 +64,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
@@ -88,6 +104,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
//! Gets CAD format name of associated provider
@@ -97,15 +131,6 @@ public:
//! Gets provider's vendor name of associated provider
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
public:
//!
const NCollection_IndexedMap<TCollection_AsciiString>& GetExternalFiles() const { return myExternalFiles; }
private:
NCollection_IndexedMap<TCollection_AsciiString> myExternalFiles; //!<
};
#endif // _RWObj_Provider_HeaderFile

View File

@@ -52,24 +52,33 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWPly_ConfigurationNode)))
return Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWPly_ConfigurationNode)))
{
Message::SendFail() << "Error: RWPly_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the RWPly_Provider during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(RWPly_ConfigurationNode) aNode =
Handle(RWPly_ConfigurationNode)::DownCast(GetNode());
Handle(RWPly_ConfigurationNode) aNode = Handle(RWPly_ConfigurationNode)::DownCast(GetNode());
TDF_LabelSequence aRootLabels;
Handle(XCAFDoc_ShapeTool) aShapeTool =
XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aShapeTool->GetFreeShapes(aRootLabels);
if (aRootLabels.IsEmpty())
{
return Standard_True;
}
TColStd_IndexedDataMapOfStringString aFileInfo;
if (!aNode->InternalParameters.WriteAuthor.IsEmpty())
{
@@ -93,8 +102,8 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
aPlyCtx.SetFaceId(aNode->InternalParameters.WriteFaceId);
if (!aPlyCtx.Perform(theDocument, aFileInfo, theProgress))
{
Message::SendFail() << "Error: RWObj_Provider : [" <<
thePath << "] : Cannot write any relevant data to the Ply file";
Message::SendFail() << "Error in the RWPly_Provider during writing the file "
<< thePath << "\t: Cannot perform the document";
return false;
}
@@ -111,10 +120,21 @@ bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool RWPly_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
return Write(thePath, aDoc, theWS, theProgress);
return Write(thePath, aDoc, theProgress);
}
//=======================================================================

View File

@@ -53,6 +53,15 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
@@ -64,6 +73,15 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
//! Gets CAD format name of associated provider

View File

@@ -106,11 +106,6 @@ void RWStepShape_RWEdgeLoop::Check
Standard_Boolean headToTail = Standard_True;
//Standard_Boolean noIdentVtx = Standard_True; //szv#4:S4163:12Mar99 unused
Standard_Integer nbEdg = ent->NbEdgeList();
if (nbEdg == 0)
{
ach->AddFail("Edge loop contains empty edge list");
return;
}
Handle(StepShape_OrientedEdge) theOE = ent->EdgeListValue(1);
Handle(StepShape_Vertex) theVxFrst = theOE->EdgeStart();
Handle(StepShape_Vertex) theVxLst = theOE->EdgeEnd();

View File

@@ -56,8 +56,8 @@ bool RWStl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRes
InternalParameters.ReadMergeAngle =
theResource->RealVal("read.merge.angle", InternalParameters.ReadMergeAngle, aScope);
InternalParameters.ReadShapeType = (ReadMode_ShapeType)
theResource->IntegerVal("read.brep", InternalParameters.ReadShapeType, aScope);
InternalParameters.ReadBRep =
theResource->BooleanVal("read.brep", InternalParameters.ReadBRep, aScope);
InternalParameters.WriteAscii =
theResource->BooleanVal("write.ascii", InternalParameters.WriteAscii, aScope);
return true;
@@ -85,9 +85,9 @@ TCollection_AsciiString RWStl_ConfigurationNode::Save() const
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines result type of transferred shape\n";
aResult += "!Default value: 1(SingleMesh). Available values: 0(MultiMesh), 1(SingleMesh), 2(CompShape)\n";
aResult += aScope + "read.brep :\t " + InternalParameters.ReadShapeType + "\n";
aResult += "!Setting up Boundary Representation flag\n";
aResult += "!Default value: false. Available values: \"on\", \"off\"\n";
aResult += aScope + "read.brep :\t " + InternalParameters.ReadBRep + "\n";
aResult += "!\n";
aResult += "!\n";

View File

@@ -84,17 +84,11 @@ public:
Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
public:
enum ReadMode_ShapeType
{
ReadMode_ShapeType_MultiMesh = 0,
ReadMode_ShapeType_SingleMesh,
ReadMode_ShapeType_CompShape,
};
struct RWStl_InternalSection
{
// Read
double ReadMergeAngle = 90.; //!< Input merge angle value
ReadMode_ShapeType ReadShapeType = ReadMode_ShapeType_SingleMesh; //!< Defines result type of transferred shape
bool ReadBRep = false; //!< Setting up Boundary Representation flag
// Write
bool WriteAscii = true; //!< Setting up writing mode (Ascii or Binary)

View File

@@ -51,21 +51,7 @@ bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
if (theDocument.IsNull())
{
Message::SendFail() << "Error: RWStl_Provider : "
<< "Null document";
return false;
}
TopoDS_Shape aShape;
if (!Read(thePath, aShape, theWS, theProgress))
{
return false;
}
Handle(XCAFDoc_ShapeTool) aShapeTool =
XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aShapeTool->AddShape(aShape);
return true;
return Read(thePath, theDocument, theProgress);
}
//=======================================================================
@@ -78,15 +64,49 @@ bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
return false;
}
TopoDS_Shape aShape;
if (!Read(thePath, aShape, theProgress))
{
return false;
}
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aShapeTool->AddShape(aShape);
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
TopoDS_Shape aShape;
TDF_LabelSequence aLabels;
Handle(XCAFDoc_ShapeTool) aSTool =
XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aSTool->GetFreeShapes(aLabels);
if (aLabels.Length() <= 0)
{
Message::SendFail() << "Error: RWStl_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the RWStl_Provider during writing the file " <<
thePath << "\t: Document contain no shapes";
return false;
}
@@ -106,7 +126,7 @@ bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
}
aShape = aComp;
}
return Write(thePath, aShape, theWS, theProgress);
return Write(thePath, aShape, theProgress);
}
//=======================================================================
@@ -119,87 +139,7 @@ bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
Message::SendWarning()
<< "OCCT Stl reader does not support model scaling according to custom length unit";
if (!GetNode()->IsKind(STANDARD_TYPE(RWStl_ConfigurationNode)))
{
Message::SendFail() << "Error: RWStl_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(RWStl_ConfigurationNode) aNode =
Handle(RWStl_ConfigurationNode)::DownCast(GetNode());
double aMergeAngle = aNode->InternalParameters.ReadMergeAngle * M_PI / 180.0;
if (aMergeAngle < 0.0 || aMergeAngle > M_PI_2)
{
Message::SendFail() << "Error: RWStl_Provider : ["
<< aMergeAngle << "] The merge angle is out of the valid range";
return false;
}
switch (aNode->InternalParameters.ReadShapeType)
{
case(RWStl_ConfigurationNode::ReadMode_ShapeType_MultiMesh):
{
NCollection_Sequence<Handle(Poly_Triangulation)> aTriangList;
// Read STL file to the triangulation list.
RWStl::ReadFile(thePath.ToCString(), aMergeAngle, aTriangList, theProgress);
BRep_Builder aB;
if (aTriangList.Size() == 1)
{
TopoDS_Face aFace;
aB.MakeFace(aFace);
aB.UpdateFace(aFace, aTriangList.First());
theShape = aFace;
}
else
{
TopoDS_Compound aCmp;
for (NCollection_Sequence<Handle(Poly_Triangulation)>::Iterator anIt(aTriangList);
anIt.More(); anIt.Next())
{
if (aCmp.IsNull())
{
aB.MakeCompound(aCmp);
}
TopoDS_Face aFace;
aB.MakeFace(aFace, anIt.Value());
aB.Add(aCmp, aFace);
}
theShape = aCmp;
}
break;
}
case(RWStl_ConfigurationNode::ReadMode_ShapeType_SingleMesh):
{
// Read STL file to the triangulation.
Handle(Poly_Triangulation) aTriangulation =
RWStl::ReadFile(thePath.ToCString(), aMergeAngle, theProgress);
if (!aTriangulation.IsNull())
{
TopoDS_Face aFace;
BRep_Builder aB;
aB.MakeFace(aFace);
aB.UpdateFace(aFace, aTriangulation);
theShape = aFace;
}
break;
}
case(RWStl_ConfigurationNode::ReadMode_ShapeType_CompShape):
{
Standard_DISABLE_DEPRECATION_WARNINGS
StlAPI::Read(theShape, thePath.ToCString());
Standard_ENABLE_DEPRECATION_WARNINGS
break;
}
}
if (theShape.IsNull())
{
Message::SendFail() << "Error: RWStl_Provider : [" <<
thePath << "] : Cannot read any relevant data from the STL file";
return false;
}
return true;
return Read(thePath, theShape, theProgress);
}
//=======================================================================
@@ -212,24 +152,81 @@ bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
Message::SendWarning() <<
"OCCT Stl writer does not support model scaling according to custom length unit";
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(RWStl_ConfigurationNode)))
return Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Message::SendWarning() << "OCCT Stl reader does not support model scaling according to custom length unit";
if (!GetNode()->IsKind(STANDARD_TYPE(RWStl_ConfigurationNode)))
{
Message::SendFail() << "Error: RWStl_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return true;
}
Handle(RWStl_ConfigurationNode) aNode = Handle(RWStl_ConfigurationNode)::DownCast(GetNode());
double aMergeAngle = aNode->InternalParameters.ReadMergeAngle * M_PI / 180.0;
if(aMergeAngle != M_PI_2)
{
if (aMergeAngle < 0.0 || aMergeAngle > M_PI_2)
{
Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
thePath << "\t: The merge angle is out of the valid range";
return false;
}
}
if (!aNode->InternalParameters.ReadBRep)
{
Handle(Poly_Triangulation) aTriangulation = RWStl::ReadFile(thePath.ToCString(), aMergeAngle, theProgress);
TopoDS_Face aFace;
BRep_Builder aB;
aB.MakeFace(aFace);
aB.UpdateFace(aFace, aTriangulation);
theShape = aFace;
}
else
{
Standard_DISABLE_DEPRECATION_WARNINGS
if (!StlAPI::Read(theShape, thePath.ToCString()))
{
Message::SendFail() << "Error in the RWStl_Provider during reading the file " << thePath;
return false;
}
Standard_ENABLE_DEPRECATION_WARNINGS
}
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool RWStl_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Message::SendWarning() << "OCCT Stl writer does not support model scaling according to custom length unit";
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(RWStl_ConfigurationNode)))
{
Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(RWStl_ConfigurationNode) aNode =
Handle(RWStl_ConfigurationNode)::DownCast(GetNode());
Handle(RWStl_ConfigurationNode) aNode = Handle(RWStl_ConfigurationNode)::DownCast(GetNode());
StlAPI_Writer aWriter;
aWriter.ASCIIMode() = aNode->InternalParameters.WriteAscii;
if (!aWriter.Write(theShape, thePath.ToCString(), theProgress))
{
Message::SendFail() << "Error: RWStl_Provider : [" <<
thePath << "] : Mesh writing has been failed";
Message::SendFail() << "Error in the RWStl_Provider during reading the file " <<
thePath << "\t: Mesh writing has been failed";
return false;
}
return true;

View File

@@ -64,6 +64,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
@@ -86,6 +104,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
//! Gets CAD format name of associated provider

View File

@@ -131,12 +131,8 @@ bool STEPCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext
theResource->IntegerVal("write.unit", InternalParameters.WriteUnit, aScope);
InternalParameters.WriteResourceName =
theResource->StringVal("write.resource.name", InternalParameters.WriteResourceName, aScope);
InternalParameters.WriteMultiPrefix =
theResource->StringVal("write.multi.prefix", InternalParameters.WriteMultiPrefix, aScope);
InternalParameters.WriteSequence =
theResource->StringVal("write.sequence", InternalParameters.WriteSequence, aScope);
InternalParameters.WriteLabels =
theResource->StringSeqVal("write.labels", InternalParameters.WriteLabels, aScope);
InternalParameters.WriteVertexMode = (WriteMode_VertexMode)
theResource->IntegerVal("write.vertex.mode", InternalParameters.WriteVertexMode, aScope);
InternalParameters.WriteSubshapeNames =
@@ -431,30 +427,12 @@ TCollection_AsciiString STEPCAFControl_ConfigurationNode::Save() const
aResult += aScope + "write.resource.name :\t " + InternalParameters.WriteResourceName + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines prefix for names of external files, if empty do not make multifile\n";
aResult += "!Default value: empty. Available values: <string>\n";
aResult += aScope + "write.multi.prefix :\t " + InternalParameters.WriteMultiPrefix + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines name of the sequence of operators\n";
aResult += "!Default value: \"ToSTEP\". Available values: <string>\n";
aResult += aScope + "write.sequence :\t " + InternalParameters.WriteSequence + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines list of shape labels to export, if empty import full document\n";
aResult += "!Default value: empty. Available values: sequense of label entries\n";
aResult += aScope + "write.labels :\t ";
for (TColStd_ListOfAsciiString::Iterator anIter(InternalParameters.WriteLabels);
anIter.More(); anIter.Next())
{
aResult += anIter.Value();
aResult += " ";
}
aResult += "\n!\n";
aResult += "!\n";
aResult += "!This parameter indicates which of free vertices writing mode is switch on\n";
aResult += "!Default value: 0(\"One Compound\"). Available values: 0(\"One Compound\"), 1(\"Signle Vertex\")\n";
@@ -539,15 +517,6 @@ bool STEPCAFControl_ConfigurationNode::IsExportSupported() const
return true;
}
//=======================================================================
// function : IsExportSupported
// purpose :
//=======================================================================
bool STEPCAFControl_ConfigurationNode::IsStreamSupported() const
{
return true;
}
//=======================================================================
// function : GetFormat
// purpose :

View File

@@ -17,7 +17,6 @@
#include <DE_ConfigurationNode.hxx>
#include <STEPControl_StepModelType.hxx>
#include <Resource_FormatType.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <UnitsMethods_LengthUnit.hxx>
//! The purpose of this class is to configure the transfer process for STEP format
@@ -70,10 +69,6 @@ public:
//! @return true if export is supported
Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
//! Checks the stream for import/export supporting
//! @return Standard_True if stream is support
Standard_EXPORT virtual bool IsStreamSupported() const Standard_OVERRIDE;
//! Gets CAD format name of associated provider
//! @return provider CAD format
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
@@ -223,9 +218,7 @@ public:
bool WriteSurfaceCurMode = true; //<! Indicates whether parametric curves (curves in parametric space of surface) should be written into the STEP file
UnitsMethods_LengthUnit WriteUnit = UnitsMethods_LengthUnit_Millimeter; //<! Defines a unit in which the STEP file should be written
TCollection_AsciiString WriteResourceName = "STEP"; //<! Defines the name of the resource file to write
TCollection_AsciiString WriteMultiPrefix; //<! Defines prefix for names of external files, if empty do not make multifile
TCollection_AsciiString WriteSequence = "ToSTEP"; //<! Defines the name of the sequence of operators to write
TColStd_ListOfAsciiString WriteLabels; //<! Defines list of shape labels to export, if empty import full document
WriteMode_VertexMode WriteVertexMode = WriteMode_VertexMode_OneCompound; //<! Indicates which of free vertices writing mode is switch on
bool WriteSubshapeNames = false; //<! Indicates whether to write sub-shape names to 'Name' attributes of STEP Representation Items
bool WriteColor = true; //<! ColorMode is used to indicate write Colors or not

View File

@@ -13,256 +13,19 @@
#include <STEPCAFControl_Provider.hxx>
#include <BinXCAFDrivers.hxx>
#include <Interface_Static.hxx>
#include <Message.hxx>
#include <StepData_StepModel.hxx>
#include <STEPCAFControl_ConfigurationNode.hxx>
#include <STEPCAFControl_Controller.hxx>
#include <STEPCAFControl_Reader.hxx>
#include <STEPCAFControl_Writer.hxx>
#include <STEPControl_ActorWrite.hxx>
#include <STEPControl_Controller.hxx>
#include <StepData_StepModel.hxx>
#include <TDataStd_Name.hxx>
#include <TDF_Tool.hxx>
#include <TDocStd_Document.hxx>
#include <UnitsMethods.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
IMPLEMENT_STANDARD_RTTIEXT(STEPCAFControl_Provider, DE_Provider)
namespace
{
//! Special class to handle static parameters.
//! Initialize all parameters in the begin of life
//! and reset changed parameters in the end of life
class STEPCAFControl_ParameterController
{
public:
STEPCAFControl_ParameterController(const Handle(STEPCAFControl_ConfigurationNode)& theNode,
const Standard_Boolean theUpdateStatic);
~STEPCAFControl_ParameterController();
protected:
void setStatic(const STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection theParameter);
private:
bool myToUpdateStaticParameters; //!< Flag to updating static parameters
STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection myOldValues; //!< Container to save previous static parameters
};
//=======================================================================
// function : STEPCAFControl_ParameterController
// purpose :
//=======================================================================
STEPCAFControl_ParameterController::STEPCAFControl_ParameterController(const Handle(STEPCAFControl_ConfigurationNode)& theNode,
const Standard_Boolean theUpdateStatic)
: myToUpdateStaticParameters(theUpdateStatic)
{
STEPCAFControl_Controller::Init();
STEPControl_Controller::Init();
if (!myToUpdateStaticParameters)
{
return;
}
// Get previous values
myOldValues.ReadBSplineContinuity =
(STEPCAFControl_ConfigurationNode::ReadMode_BSplineContinuity)
Interface_Static::IVal("read.iges.bspline.continuity");
myOldValues.ReadPrecisionMode =
(STEPCAFControl_ConfigurationNode::ReadMode_Precision)
Interface_Static::IVal("read.precision.mode");
myOldValues.ReadPrecisionVal =
Interface_Static::RVal("read.precision.val");
myOldValues.ReadMaxPrecisionMode =
(STEPCAFControl_ConfigurationNode::ReadMode_MaxPrecision)
Interface_Static::IVal("read.maxprecision.mode");
myOldValues.ReadMaxPrecisionVal =
Interface_Static::RVal("read.maxprecision.val");
myOldValues.ReadSameParamMode =
Interface_Static::IVal("read.stdsameparameter.mode") == 1;
myOldValues.ReadSurfaceCurveMode =
(STEPCAFControl_ConfigurationNode::ReadMode_SurfaceCurve)
Interface_Static::IVal("read.surfacecurve.mode");
myOldValues.EncodeRegAngle =
Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
myOldValues.AngleUnit =
(STEPCAFControl_ConfigurationNode::AngleUnitMode)
Interface_Static::IVal("step.angleunit.mode");
myOldValues.ReadResourceName =
Interface_Static::CVal("read.step.resource.name");
myOldValues.ReadSequence =
Interface_Static::CVal("read.step.sequence");
myOldValues.ReadProductMode =
Interface_Static::IVal("read.step.product.mode") == 1;
myOldValues.ReadProductContext =
(STEPCAFControl_ConfigurationNode::ReadMode_ProductContext)
Interface_Static::IVal("read.step.product.context");
myOldValues.ReadShapeRepr =
(STEPCAFControl_ConfigurationNode::ReadMode_ShapeRepr)
Interface_Static::IVal("read.step.shape.repr");
myOldValues.ReadTessellated =
(STEPCAFControl_ConfigurationNode::RWMode_Tessellated)
Interface_Static::IVal("read.step.tessellated");
myOldValues.ReadAssemblyLevel =
(STEPCAFControl_ConfigurationNode::ReadMode_AssemblyLevel)
Interface_Static::IVal("read.step.assembly.level");
myOldValues.ReadRelationship =
Interface_Static::IVal("read.step.shape.relationship") == 1;
myOldValues.ReadShapeAspect =
Interface_Static::IVal("read.step.shape.aspect") == 1;
myOldValues.ReadConstrRelation =
Interface_Static::IVal("read.step.constructivegeom.relationship") == 1;
myOldValues.ReadSubshapeNames =
Interface_Static::IVal("read.stepcaf.subshapes.name") == 1;
myOldValues.ReadCodePage =
(Resource_FormatType)Interface_Static::IVal("read.step.codepage");
myOldValues.ReadNonmanifold =
Interface_Static::IVal("read.step.nonmanifold") == 1;
myOldValues.ReadIdeas =
Interface_Static::IVal("read.step.ideas") == 1;
myOldValues.ReadAllShapes =
Interface_Static::IVal("read.step.all.shapes") == 1;
myOldValues.ReadRootTransformation =
Interface_Static::IVal("read.step.root.transformation") == 1;
myOldValues.WritePrecisionMode =
(STEPCAFControl_ConfigurationNode::WriteMode_PrecisionMode)
Interface_Static::IVal("write.precision.mode");
myOldValues.WritePrecisionVal =
Interface_Static::RVal("write.precision.val");
myOldValues.WriteAssembly =
(STEPCAFControl_ConfigurationNode::WriteMode_Assembly)
Interface_Static::IVal("write.step.assembly");
myOldValues.WriteSchema =
(STEPCAFControl_ConfigurationNode::WriteMode_StepSchema)
Interface_Static::IVal("write.step.schema");
myOldValues.WriteTessellated =
(STEPCAFControl_ConfigurationNode::RWMode_Tessellated)
Interface_Static::IVal("write.step.tessellated");
myOldValues.WriteProductName =
Interface_Static::CVal("write.step.product.name");
myOldValues.WriteSurfaceCurMode =
Interface_Static::IVal("write.surfacecurve.mode") == 1;
myOldValues.WriteUnit =
(UnitsMethods_LengthUnit)Interface_Static::IVal("write.step.unit");
myOldValues.WriteResourceName =
Interface_Static::CVal("write.resource.name");
myOldValues.WriteSequence =
Interface_Static::CVal("write.step.sequence");
myOldValues.WriteVertexMode =
(STEPCAFControl_ConfigurationNode::WriteMode_VertexMode)
Interface_Static::IVal("write.step.vertex.mode");
myOldValues.WriteSubshapeNames =
Interface_Static::IVal("write.stepcaf.subshapes.name") == 1;
// Set new values
setStatic(theNode->InternalParameters);
}
//=======================================================================
// function : ~STEPCAFControl_ParameterController
// purpose :
//=======================================================================
STEPCAFControl_ParameterController::~STEPCAFControl_ParameterController()
{
if (!myToUpdateStaticParameters)
{
return;
}
setStatic(myOldValues);
}
//=======================================================================
// function : setStatic
// purpose :
//=======================================================================
void STEPCAFControl_ParameterController::setStatic(const STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection theParameter)
{
Interface_Static::SetIVal("read.iges.bspline.continuity",
theParameter.ReadBSplineContinuity);
Interface_Static::SetIVal("read.precision.mode",
theParameter.ReadPrecisionMode);
Interface_Static::SetRVal("read.precision.val",
theParameter.ReadPrecisionVal);
Interface_Static::SetIVal("read.maxprecision.mode",
theParameter.ReadMaxPrecisionMode);
Interface_Static::SetRVal("read.maxprecision.val",
theParameter.ReadMaxPrecisionVal);
Interface_Static::SetIVal("read.stdsameparameter.mode",
theParameter.ReadSameParamMode);
Interface_Static::SetIVal("read.surfacecurve.mode",
theParameter.ReadSurfaceCurveMode);
Interface_Static::SetRVal("read.encoderegularity.angle",
theParameter.EncodeRegAngle * M_PI / 180.0);
Interface_Static::SetIVal("step.angleunit.mode",
theParameter.AngleUnit);
Interface_Static::SetCVal("read.step.resource.name",
theParameter.ReadResourceName.ToCString());
Interface_Static::SetCVal("read.step.sequence",
theParameter.ReadSequence.ToCString());
Interface_Static::SetIVal("read.step.product.mode",
theParameter.ReadProductMode);
Interface_Static::SetIVal("read.step.product.context",
theParameter.ReadProductContext);
Interface_Static::SetIVal("read.step.shape.repr",
theParameter.ReadShapeRepr);
Interface_Static::SetIVal("read.step.tessellated",
theParameter.ReadTessellated);
Interface_Static::SetIVal("read.step.assembly.level",
theParameter.ReadAssemblyLevel);
Interface_Static::SetIVal("read.step.shape.relationship",
theParameter.ReadRelationship);
Interface_Static::SetIVal("read.step.shape.aspect",
theParameter.ReadShapeAspect);
Interface_Static::SetIVal("read.step.constructivegeom.relationship",
theParameter.ReadConstrRelation);
Interface_Static::SetIVal("read.stepcaf.subshapes.name",
theParameter.ReadSubshapeNames);
Interface_Static::SetIVal("read.step.codepage",
theParameter.ReadCodePage);
Interface_Static::SetIVal("read.step.nonmanifold",
theParameter.ReadNonmanifold);
Interface_Static::SetIVal("read.step.ideas",
theParameter.ReadIdeas);
Interface_Static::SetIVal("read.step.all.shapes",
theParameter.ReadAllShapes);
Interface_Static::SetIVal("read.step.root.transformation",
theParameter.ReadRootTransformation);
Interface_Static::SetIVal("write.precision.mode",
theParameter.WritePrecisionMode);
Interface_Static::SetRVal("write.precision.val",
theParameter.WritePrecisionVal);
Interface_Static::SetIVal("write.step.assembly",
theParameter.WriteAssembly);
Interface_Static::SetIVal("write.step.schema",
theParameter.WriteSchema);
Interface_Static::SetIVal("write.step.tessellated",
theParameter.WriteTessellated);
Interface_Static::SetCVal("write.step.product.name",
theParameter.WriteProductName.ToCString());
Interface_Static::SetIVal("write.surfacecurve.mode",
theParameter.WriteSurfaceCurMode);
Interface_Static::SetIVal("write.step.unit",
theParameter.WriteUnit);
Interface_Static::SetCVal("write.resource.name",
theParameter.WriteResourceName.ToCString());
Interface_Static::SetCVal("write.step.sequence",
theParameter.WriteSequence.ToCString());
Interface_Static::SetIVal("write.step.vertex.mode",
theParameter.WriteVertexMode);
Interface_Static::SetIVal("write.stepcaf.subshapes.name",
theParameter.WriteSubshapeNames);
}
}
//=======================================================================
// function : STEPCAFControl_Provider
// purpose :
@@ -279,23 +42,113 @@ STEPCAFControl_Provider::STEPCAFControl_Provider(const Handle(DE_ConfigurationNo
{}
//=======================================================================
// function : personizeWS
// function : initStatic
// purpose :
//=======================================================================
void STEPCAFControl_Provider::personizeWS(Handle(XSControl_WorkSession)& theWS)
void STEPCAFControl_Provider::initStatic(const Handle(DE_ConfigurationNode)& theNode)
{
if (theWS.IsNull())
{
Message::SendWarning() << "Warning: STEPCAFControl_Provider :"
<< " Null work session, use internal temporary session";
theWS = new XSControl_WorkSession();
}
Handle(STEPControl_Controller) aCntrl =
Handle(STEPControl_Controller)::DownCast(theWS->NormAdaptor());
if (aCntrl.IsNull())
{
theWS->SelectNorm("STEP");
}
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(theNode);
STEPCAFControl_Controller::Init();
// Get previous values
myOldValues.ReadBSplineContinuity = (STEPCAFControl_ConfigurationNode::ReadMode_BSplineContinuity)Interface_Static::IVal("read.iges.bspline.continuity");
myOldValues.ReadPrecisionMode = (STEPCAFControl_ConfigurationNode::ReadMode_Precision)Interface_Static::IVal("read.precision.mode");
myOldValues.ReadPrecisionVal = Interface_Static::RVal("read.precision.val");
myOldValues.ReadMaxPrecisionMode = (STEPCAFControl_ConfigurationNode::ReadMode_MaxPrecision)Interface_Static::IVal("read.maxprecision.mode");
myOldValues.ReadMaxPrecisionVal = Interface_Static::RVal("read.maxprecision.val");
myOldValues.ReadSameParamMode = Interface_Static::IVal("read.stdsameparameter.mode") == 1;
myOldValues.ReadSurfaceCurveMode = (STEPCAFControl_ConfigurationNode::ReadMode_SurfaceCurve)Interface_Static::IVal("read.surfacecurve.mode");
myOldValues.EncodeRegAngle = Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
myOldValues.AngleUnit = (STEPCAFControl_ConfigurationNode::AngleUnitMode)Interface_Static::IVal("step.angleunit.mode");
myOldValues.ReadResourceName = Interface_Static::CVal("read.step.resource.name");
myOldValues.ReadSequence = Interface_Static::CVal("read.step.sequence");
myOldValues.ReadProductMode = Interface_Static::IVal("read.step.product.mode") == 1;
myOldValues.ReadProductContext = (STEPCAFControl_ConfigurationNode::ReadMode_ProductContext)Interface_Static::IVal("read.step.product.context");
myOldValues.ReadShapeRepr = (STEPCAFControl_ConfigurationNode::ReadMode_ShapeRepr)Interface_Static::IVal("read.step.shape.repr");
myOldValues.ReadTessellated = (STEPCAFControl_ConfigurationNode::RWMode_Tessellated)Interface_Static::IVal("read.step.tessellated");
myOldValues.ReadAssemblyLevel = (STEPCAFControl_ConfigurationNode::ReadMode_AssemblyLevel)Interface_Static::IVal("read.step.assembly.level");
myOldValues.ReadRelationship = Interface_Static::IVal("read.step.shape.relationship") == 1;
myOldValues.ReadShapeAspect = Interface_Static::IVal("read.step.shape.aspect") == 1;
myOldValues.ReadConstrRelation = Interface_Static::IVal("read.step.constructivegeom.relationship") == 1;
myOldValues.ReadSubshapeNames = Interface_Static::IVal("read.stepcaf.subshapes.name") == 1;
myOldValues.ReadCodePage = (Resource_FormatType)Interface_Static::IVal("read.step.codepage");
myOldValues.ReadNonmanifold = Interface_Static::IVal("read.step.nonmanifold") == 1;
myOldValues.ReadIdeas = Interface_Static::IVal("read.step.ideas") == 1;
myOldValues.ReadAllShapes = Interface_Static::IVal("read.step.all.shapes") == 1;
myOldValues.ReadRootTransformation = Interface_Static::IVal("read.step.root.transformation") == 1;
myOldValues.WritePrecisionMode = (STEPCAFControl_ConfigurationNode::WriteMode_PrecisionMode)Interface_Static::IVal("write.precision.mode");
myOldValues.WritePrecisionVal = Interface_Static::RVal("write.precision.val");
myOldValues.WriteAssembly = (STEPCAFControl_ConfigurationNode::WriteMode_Assembly)Interface_Static::IVal("write.step.assembly");
myOldValues.WriteSchema = (STEPCAFControl_ConfigurationNode::WriteMode_StepSchema)Interface_Static::IVal("write.step.schema");
myOldValues.WriteTessellated = (STEPCAFControl_ConfigurationNode::RWMode_Tessellated)Interface_Static::IVal("write.step.tessellated");
myOldValues.WriteProductName = Interface_Static::CVal("write.step.product.name");
myOldValues.WriteSurfaceCurMode = Interface_Static::IVal("write.surfacecurve.mode") == 1;
myOldValues.WriteUnit = (UnitsMethods_LengthUnit)Interface_Static::IVal("write.step.unit");
myOldValues.WriteResourceName = Interface_Static::CVal("write.resource.name");
myOldValues.WriteSequence = Interface_Static::CVal("write.step.sequence");
myOldValues.WriteVertexMode = (STEPCAFControl_ConfigurationNode::WriteMode_VertexMode)Interface_Static::IVal("write.step.vertex.mode");
myOldValues.WriteSubshapeNames = Interface_Static::IVal("write.stepcaf.subshapes.name") == 1;
// Set new values
setStatic(aNode->InternalParameters);
}
//=======================================================================
// function : setStatic
// purpose :
//=======================================================================
void STEPCAFControl_Provider::setStatic(const STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection theParameter)
{
Interface_Static::SetIVal("read.iges.bspline.continuity", theParameter.ReadBSplineContinuity);
Interface_Static::SetIVal("read.precision.mode", theParameter.ReadPrecisionMode);
Interface_Static::SetRVal("read.precision.val", theParameter.ReadPrecisionVal);
Interface_Static::SetIVal("read.maxprecision.mode", theParameter.ReadMaxPrecisionMode);
Interface_Static::SetRVal("read.maxprecision.val", theParameter.ReadMaxPrecisionVal);
Interface_Static::SetIVal("read.stdsameparameter.mode", theParameter.ReadSameParamMode);
Interface_Static::SetIVal("read.surfacecurve.mode", theParameter.ReadSurfaceCurveMode);
Interface_Static::SetRVal("read.encoderegularity.angle", theParameter.EncodeRegAngle * M_PI / 180.0);
Interface_Static::SetIVal("step.angleunit.mode", theParameter.AngleUnit);
Interface_Static::SetCVal("read.step.resource.name", theParameter.ReadResourceName.ToCString());
Interface_Static::SetCVal("read.step.sequence", theParameter.ReadSequence.ToCString());
Interface_Static::SetIVal("read.step.product.mode", theParameter.ReadProductMode);
Interface_Static::SetIVal("read.step.product.context", theParameter.ReadProductContext);
Interface_Static::SetIVal("read.step.shape.repr", theParameter.ReadShapeRepr);
Interface_Static::SetIVal("read.step.tessellated", theParameter.ReadTessellated);
Interface_Static::SetIVal("read.step.assembly.level", theParameter.ReadAssemblyLevel);
Interface_Static::SetIVal("read.step.shape.relationship", theParameter.ReadRelationship);
Interface_Static::SetIVal("read.step.shape.aspect", theParameter.ReadShapeAspect);
Interface_Static::SetIVal("read.step.constructivegeom.relationship", theParameter.ReadConstrRelation);
Interface_Static::SetIVal("read.stepcaf.subshapes.name", theParameter.ReadSubshapeNames);
Interface_Static::SetIVal("read.step.codepage", theParameter.ReadCodePage);
Interface_Static::SetIVal("read.step.nonmanifold", theParameter.ReadNonmanifold);
Interface_Static::SetIVal("read.step.ideas", theParameter.ReadIdeas);
Interface_Static::SetIVal("read.step.all.shapes", theParameter.ReadAllShapes);
Interface_Static::SetIVal("read.step.root.transformation", theParameter.ReadRootTransformation);
Interface_Static::SetIVal("write.precision.mode", theParameter.WritePrecisionMode);
Interface_Static::SetRVal("write.precision.val", theParameter.WritePrecisionVal);
Interface_Static::SetIVal("write.step.assembly", theParameter.WriteAssembly);
Interface_Static::SetIVal("write.step.schema", theParameter.WriteSchema);
Interface_Static::SetIVal("write.step.tessellated", theParameter.WriteTessellated);
Interface_Static::SetCVal("write.step.product.name", theParameter.WriteProductName.ToCString());
Interface_Static::SetIVal("write.surfacecurve.mode", theParameter.WriteSurfaceCurMode);
Interface_Static::SetIVal("write.step.unit", theParameter.WriteUnit);
Interface_Static::SetCVal("write.resource.name", theParameter.WriteResourceName.ToCString());
Interface_Static::SetCVal("write.step.sequence", theParameter.WriteSequence.ToCString());
Interface_Static::SetIVal("write.step.vertex.mode", theParameter.WriteVertexMode);
Interface_Static::SetIVal("write.stepcaf.subshapes.name", theParameter.WriteSubshapeNames);
}
//=======================================================================
// function : resetStatic
// purpose :
//=======================================================================
void STEPCAFControl_Provider::resetStatic()
{
setStatic(myOldValues);
}
//=======================================================================
@@ -309,120 +162,48 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
{
if (theDocument.IsNull())
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Null document";
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
return false;
}
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode =
Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
STEPCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
aNode->GlobalParameters.LengthUnit,
UnitsMethods_LengthUnit_Millimeter);
const Standard_Boolean toUseLoaded = thePath == ".";
TCollection_AsciiString aFile;
if (toUseLoaded)
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
STEPCAFControl_Reader aReader;
if (!theWS.IsNull())
{
aFile = theWS->LoadedFile();
Message::SendInfo() << "Model taken from the STEP session : "
<< aFile;
aReader.Init(theWS);
}
else
{
aFile = thePath;
Message::SendInfo() << "File STEP to read : "
<< aFile;
}
STEPCAFControl_Reader aReader(theWS, !toUseLoaded);
aReader.SetColorMode(aNode->InternalParameters.ReadColor);
aReader.SetNameMode(aNode->InternalParameters.ReadName);
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
aReader.SetPropsMode(aNode->InternalParameters.ReadProps);
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
if (!toUseLoaded)
{
aReadStat = aReader.ReadFile(thePath.ToCString());
}
else if (theWS->NbStartingEntities() > 0)
{
aReadStat = IFSelect_RetDone;
}
aReadStat = aReader.ReadFile(thePath.ToCString());
if (aReadStat != IFSelect_RetDone)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : ["
<< aFile << "] : abandon, no model loaded";
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: abandon";
resetStatic();
return false;
}
if (!aReader.Transfer(theDocument, theProgress))
{
Message::SendFail() << "Error: STEPCAFControl_Provider : [" <<
aFile << "] : Cannot read any relevant data from the STEP file";
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: Cannot read any relevant data from the STEP file";
resetStatic();
return false;
}
myProcessedExtFiles = aReader.ExternFiles();
return true;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool STEPCAFControl_Provider::Read(std::istream& theIStream,
const Handle(TDocStd_Document)& theDocument,
const TCollection_AsciiString theName,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Null document";
return false;
}
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode =
Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
STEPCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
aNode->GlobalParameters.LengthUnit,
UnitsMethods_LengthUnit_Millimeter);
Message::SendInfo() << "Model taken from the STEP stream";
STEPCAFControl_Reader aReader(theWS);
aReader.SetColorMode(aNode->InternalParameters.ReadColor);
aReader.SetNameMode(aNode->InternalParameters.ReadName);
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
aReader.SetPropsMode(aNode->InternalParameters.ReadProps);
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
aReadStat = aReader.ReadStream(theName.ToCString(), theIStream);
if (aReadStat != IFSelect_RetDone)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Abandon, no model loaded via stream";
return false;
}
if (!aReader.Transfer(theDocument, theProgress))
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Cannot read any relevant data from the STEP file";
return false;
}
myProcessedExtFiles = aReader.ExternFiles();
resetStatic();
return true;
}
@@ -435,176 +216,86 @@ bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode =
Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
STEPCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
aNode->GlobalParameters.LengthUnit,
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument,
UnitsMethods::GetLengthUnitScale(aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter),
UnitsMethods_LengthUnit_Millimeter);
STEPCAFControl_Writer aWriter(theWS, Standard_True);
STEPControl_StepModelType aMode =
static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
STEPCAFControl_Writer aWriter;
if (!theWS.IsNull())
{
aWriter.Init(theWS);
}
STEPControl_StepModelType aMode = static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
aWriter.SetNameMode(aNode->InternalParameters.WriteName);
aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);
aWriter.SetPropsMode(aNode->InternalParameters.WriteProps);
TDF_LabelSequence aLabels;
TCollection_AsciiString aLabelsString;
for (TColStd_ListOfAsciiString::Iterator anIter(aNode->InternalParameters.WriteLabels);
anIter.More(); anIter.Next())
TDF_Label aLabel;
if (!aWriter.Transfer(theDocument, aMode, 0, theProgress))
{
const TCollection_AsciiString& aValue = anIter.Value();
TDF_Label aLabel;
TDF_Tool::Label(theDocument->Main().Data(), aValue, aLabel, Standard_False);
if (aLabel.IsNull())
Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
thePath << "\t: The document cannot be translated or gives no result";
resetStatic();
return false;
}
IFSelect_ReturnStatus aStatus = aWriter.Write(thePath.ToCString());
switch (aStatus)
{
case IFSelect_RetVoid:
{
Message::SendFail() << "Error: No label for entry '" << aValue << "'";
Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
thePath << "\t: No file written";
resetStatic();
return false;;
}
case IFSelect_RetDone:
{
break;
}
default:
{
Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " <<
thePath << "\t: Error on writing file";
resetStatic();
return false;
}
if (!aLabelsString.IsEmpty())
{
aLabelsString += " ";
}
aLabelsString += aValue;
aLabels.Append(aLabel);
}
TCollection_ExtendedString aDocName;
Handle(TDataStd_Name) aNameAttr;
if (theDocument->GetData()->Root().FindAttribute(TDataStd_Name::GetID(), aNameAttr))
{
aDocName = aNameAttr->Get();
}
Standard_Boolean aTransferStatus = Standard_True;
Standard_CString aMultiFilePrefix = !aNode->InternalParameters.WriteMultiPrefix.IsEmpty() ?
aNode->InternalParameters.WriteMultiPrefix.ToCString() : nullptr;
Message::SendInfo() << "Writing STEP file "
<< thePath;
if (aLabels.IsEmpty())
{
Message::SendInfo() << "Translating labels "
<< aLabelsString << " of document " << aDocName << " to STEP";
aTransferStatus = aWriter.Transfer(theDocument, aMode, aMultiFilePrefix, theProgress);
}
else
{
Message::SendInfo() << "Translating document "
<< aDocName << " to STEP";
aTransferStatus = aWriter.Transfer(aLabels, aMode, aMultiFilePrefix, theProgress);
}
if (!aTransferStatus)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "The document cannot be translated or gives no result";
return false;
}
if (thePath == ".")
{
Message::SendInfo() << "Document has been translated into the session";
return true;
}
if (aWriter.Write(thePath.ToCString()) != IFSelect_RetDone)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : [" <<
thePath << "] : Write failed";
return false;
}
Message::SendInfo() << "STEP file [" << thePath << "] Successfully written";
myProcessedExtFiles = aWriter.ExternFiles();
resetStatic();
return true;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
Handle(XSControl_WorkSession) aWS;
return Read(thePath, theDocument, aWS, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool STEPCAFControl_Provider::Write(std::ostream& theOStream,
bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode =
Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
STEPCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
STEPCAFControl_Writer aWriter(theWS, Standard_True);
STEPControl_StepModelType aMode =
static_cast<STEPControl_StepModelType>(aNode->InternalParameters.WriteModelType);
aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
aWriter.SetNameMode(aNode->InternalParameters.WriteName);
aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);
aWriter.SetPropsMode(aNode->InternalParameters.WriteProps);
TDF_LabelSequence aLabels;
TCollection_AsciiString aLabelsString;
for (TColStd_ListOfAsciiString::Iterator anIter(aNode->InternalParameters.WriteLabels);
anIter.More(); anIter.Next())
{
const TCollection_AsciiString& aValue = anIter.Value();
TDF_Label aLabel;
TDF_Tool::Label(theDocument->Main().Data(), aValue, aLabel, Standard_False);
if (aLabel.IsNull())
{
Message::SendFail() << "Error: No label for entry '" << aValue << "'";
return false;
}
if (!aLabelsString.IsEmpty())
{
aLabelsString += " ";
}
aLabelsString += aValue;
aLabels.Append(aLabel);
}
TCollection_ExtendedString aDocName;
Handle(TDataStd_Name) aNameAttr;
if (theDocument->GetData()->Root().FindAttribute(TDataStd_Name::GetID(), aNameAttr))
{
aDocName = aNameAttr->Get();
}
Standard_Boolean aTransferStatus = Standard_True;
Standard_CString aMultiFilePrefix = !aNode->InternalParameters.WriteMultiPrefix.IsEmpty() ?
aNode->InternalParameters.WriteMultiPrefix.ToCString() : nullptr;
Message::SendInfo() << "Writing STEP file to stream";
if (aLabels.IsEmpty())
{
Message::SendInfo() << "Translating labels "
<< aLabelsString << " of document " << aDocName << " to STEP";
aTransferStatus = aWriter.Transfer(theDocument, aMode, aMultiFilePrefix, theProgress);
}
else
{
Message::SendInfo() << "Translating document "
<< aDocName << " to STEP";
aTransferStatus = aWriter.Transfer(aLabels, aMode, aMultiFilePrefix, theProgress);
}
if (!aTransferStatus)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "The document cannot be translated or gives no result";
return false;
}
if (aWriter.WriteStream(theOStream) != IFSelect_RetDone)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : Write to stream failed";
return false;
}
Message::SendInfo() << "STEP file to stream successfully written";
myProcessedExtFiles = aWriter.ExternFiles();
return true;
Handle(XSControl_WorkSession) aWS;
return Write(thePath, theDocument, aWS, theProgress);
}
//=======================================================================
@@ -617,74 +308,39 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theProgress;
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode =
Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
STEPCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
STEPControl_Reader aReader(theWS);
if (aReader.ReadFile(thePath.ToCString()) != IFSelect_RetDone)
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
STEPControl_Reader aReader;
if(!theWS.IsNull())
{
Message::SendFail() << "Error: STEPCAFControl_Provider : ["
<< thePath << "] : abandon, no model loaded";
aReader.SetWS(theWS);
}
IFSelect_ReturnStatus aReadstat = IFSelect_RetVoid;
aReadstat = aReader.ReadFile(thePath.ToCString());
if (aReadstat != IFSelect_RetDone)
{
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: abandon, no model loaded";
resetStatic();
return false;
}
Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(aReader.Model());
aModel->SetLocalLengthUnit(aNode->GlobalParameters.LengthUnit);
if (aReader.TransferRoots() <= 0)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : [" <<
thePath << "] : Cannot read any relevant data from the STEP file";
return false;
}
theShape = aReader.OneShape();
return true;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool STEPCAFControl_Provider::Read(std::istream& theIStream,
TopoDS_Shape& theShape,
const TCollection_AsciiString theName,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theProgress;
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode =
Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
STEPCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
STEPControl_Reader aReader(theWS);
if (aReader.ReadStream(theName.ToCString(), theIStream) != IFSelect_RetDone)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Abandon, no model loaded from STEP stream";
return false;
}
Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(aReader.Model());
aModel->SetLocalLengthUnit(aNode->GlobalParameters.LengthUnit);
if (aReader.TransferRoots() <= 0)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Cannot read any relevant data from the STEP stream";
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t:Cannot read any relevant data from the STEP file";
resetStatic();
return false;
}
theShape = aReader.OneShape();
resetStatic();
return true;
}
@@ -697,94 +353,63 @@ bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode =
Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
STEPCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
STEPControl_Writer aWriter(theWS, Standard_True);
Handle(StepData_StepModel) aModel = aWriter.Model();
Standard_Integer aNbEntities = (aModel.IsNull() ? 0 : aModel->NbEntities());
aModel->SetWriteLengthUnit(UnitsMethods::GetLengthUnitScale(
aNode->InternalParameters.WriteUnit,
UnitsMethods_LengthUnit_Millimeter));
IFSelect_ReturnStatus aWritestat =
aWriter.Transfer(theShape, aNode->InternalParameters.WriteModelType, true, theProgress);
if (aNbEntities > 0)
Handle(STEPCAFControl_ConfigurationNode) aNode = Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
STEPControl_Writer aWriter;
if(!theWS.IsNull())
{
Message::SendTrace() << "STEPCAFControl_Provider : Model not empty before transferring";
aWriter.SetWS(theWS);
}
IFSelect_ReturnStatus aWritestat = IFSelect_RetVoid;
Handle(StepData_StepModel) aModel = aWriter.Model();
aModel->SetWriteLengthUnit(UnitsMethods::GetLengthUnitScale(aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter));
aWritestat = aWriter.Transfer(theShape, aNode->InternalParameters.WriteModelType, true, theProgress);
if (aWritestat != IFSelect_RetDone)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Can't translate shape to STEP model";
Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " <<
thePath << "\t: abandon, no model loaded";
resetStatic();
return false;
}
if (thePath == ".")
{
Message::SendInfo() << "Step model has been translated into the session";
return true;
}
if (aWriter.Write(thePath.ToCString()) != IFSelect_RetDone)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Can't write STEP file " << thePath;
Message::SendFail() << "STEPCAFControl_Provider: Error on writing file";
resetStatic();
return false;
}
resetStatic();
return true;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(XSControl_WorkSession) aWS;
return Read(thePath, theShape, aWS, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool STEPCAFControl_Provider::Write(std::ostream& theOStream,
bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() ||
!GetNode()->IsKind(STANDARD_TYPE(STEPCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Incorrect or empty Configuration Node";
return false;
}
Handle(STEPCAFControl_ConfigurationNode) aNode =
Handle(STEPCAFControl_ConfigurationNode)::DownCast(GetNode());
STEPCAFControl_ParameterController aParamController(aNode, myToUpdateStaticParameters);
personizeWS(theWS);
STEPControl_Writer aWriter(theWS, Standard_True);
Handle(StepData_StepModel) aModel = aWriter.Model();
Standard_Integer aNbEntities = (aModel.IsNull() ? 0 : aModel->NbEntities());
aModel->SetWriteLengthUnit(UnitsMethods::GetLengthUnitScale(
aNode->InternalParameters.WriteUnit,
UnitsMethods_LengthUnit_Millimeter));
IFSelect_ReturnStatus aWritestat =
aWriter.Transfer(theShape, aNode->InternalParameters.WriteModelType, true, theProgress);
if (aNbEntities > 0)
{
Message::SendTrace() << "STEPCAFControl_Provider : Model not empty before transferring";
}
if (aWritestat != IFSelect_RetDone)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Can't translate shape to STEP model";
return false;
}
if (aWriter.WriteStream(theOStream) != IFSelect_RetDone)
{
Message::SendFail() << "Error: STEPCAFControl_Provider : "
<< "Can't write STEP to stream";
return false;
}
return true;
Handle(XSControl_WorkSession) aWS;
return Write(thePath, theShape, aWS, theProgress);
}
//=======================================================================

View File

@@ -16,7 +16,6 @@
#include <DE_Provider.hxx>
#include <STEPCAFControl_ConfigurationNode.hxx>
#include <STEPCAFControl_ExternFile.hxx>
//! The class to transfer STEP files.
//! Reads and Writes any STEP files into/from OCCT.
@@ -55,19 +54,6 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] theIStream stream to import STEP data
//! @param[out] theDocument document to save result
//! @paramp[in] theName name of step file, can be empty
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(std::istream& theIStream,
const Handle(TDocStd_Document)& theDocument,
const TCollection_AsciiString theName,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
@@ -79,16 +65,23 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] theOStream stream to export STEP data
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(std::ostream& theOStream,
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
@@ -101,19 +94,6 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] theIStream stream to the step file
//! @param[out] theShape shape to save result
//! @paramp[in] theName name of step file, can be empty
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(std::istream& theIStream,
TopoDS_Shape& theShape,
const TCollection_AsciiString theName,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
@@ -125,16 +105,23 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] theOStream stream to export STEP data
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(std::ostream& theOStream,
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
@@ -146,34 +133,18 @@ public:
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
public:
private:
//! Sets parameter to update static parameter, that true by default
void SetToUpdateStaticParameters(const bool theToUpdate) { myToUpdateStaticParameters = theToUpdate; }
//! Initialize static variables
void initStatic(const Handle(DE_ConfigurationNode)& theNode);
//! Gets parameter to update static parameter, that true by default
bool ToUpdateStaticParameters() const { return myToUpdateStaticParameters; }
//! Initialize static variables
void setStatic(const STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection theParameter);
public:
//! Reset used interface static variables
void resetStatic();
//! Gets external files used in the last read or write process.
//! Processed only on multifile setting up
NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> GetExternalFiles() const
{
return myProcessedExtFiles;
}
private:
//! Personizes work session with current format.
//! Creates new temporary session if current session is null
//! @param[in] theWS current work session
void personizeWS(Handle(XSControl_WorkSession)& theWS);
private:
bool myToUpdateStaticParameters = true; //!< Flag to updating static parameters
NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myProcessedExtFiles; //!< External files from the last operation
STEPCAFControl_ConfigurationNode::STEPCAFControl_InternalSection myOldValues;
};

File diff suppressed because it is too large Load Diff

View File

@@ -31,7 +31,6 @@
#include <StepVisual_DraughtingModel.hxx>
#include <StepVisual_HArray1OfPresentationStyleAssignment.hxx>
#include <TDF_LabelSequence.hxx>
#include <TDF_LabelMap.hxx>
#include <XCAFDimTolObjects_GeomToleranceObject.hxx>
class XSControl_WorkSession;
@@ -45,234 +44,219 @@ class TopoDS_Shape;
//! colors and part names
//!
//! Also supports multifile writing
class STEPCAFControl_Writer
class STEPCAFControl_Writer
{
DEFINE_STANDARD_ALLOC
public:
DEFINE_STANDARD_ALLOC
//! Creates a writer with an empty
//! STEP model and sets ColorMode, LayerMode, NameMode and
//! PropsMode to Standard_True.
Standard_EXPORT STEPCAFControl_Writer();
//! Creates a reader tool and attaches it to an already existing Session
//! Clears the session if it was not yet set for STEP
//! Clears the internal data structures
Standard_EXPORT STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& theWS,
const Standard_Boolean theScratch = Standard_True);
Standard_EXPORT STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
//! Clears the internal data structures and attaches to a new session
//! Clears the session if it was not yet set for STEP
Standard_EXPORT void Init(const Handle(XSControl_WorkSession)& theWS,
const Standard_Boolean theScratch = Standard_True);
Standard_EXPORT void Init (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
//! Writes all the produced models into file
//! In case of multimodel with extern references,
//! filename will be a name of root file, all other files
//! have names of corresponding parts
//! Provided for use like single-file writer
Standard_EXPORT IFSelect_ReturnStatus Write(const Standard_CString theFileName);
Standard_EXPORT IFSelect_ReturnStatus Write (const Standard_CString theFileName);
//! Writes all the produced models into the stream.
//! Provided for use like single-file writer
Standard_EXPORT IFSelect_ReturnStatus WriteStream(std::ostream& theStream);
Standard_EXPORT IFSelect_ReturnStatus WriteStream (std::ostream& theStream);
//! Transfers a document (or single label) to a STEP model
//! The mode of translation of shape is AsIs
//! If multi is not null pointer, it switches to multifile
//! mode (with external refs), and string pointed by <multi>
//! gives prefix for names of extern files (can be empty string)
//! Returns True if translation is OK
Standard_EXPORT Standard_Boolean Transfer(const Handle(TDocStd_Document)& theDoc,
const STEPControl_StepModelType theMode = STEPControl_AsIs,
const Standard_CString theIsMulti = 0,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT Standard_Boolean Transfer (const Handle(TDocStd_Document)& doc,
const STEPControl_StepModelType mode = STEPControl_AsIs,
const Standard_CString multi = 0,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Method to transfer part of the document specified by label
Standard_EXPORT Standard_Boolean Transfer(const TDF_Label& theLabel,
const STEPControl_StepModelType theMode = STEPControl_AsIs,
const Standard_CString theIsMulti = 0,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT Standard_Boolean Transfer (const TDF_Label& L,
const STEPControl_StepModelType mode = STEPControl_AsIs,
const Standard_CString multi = 0,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Mehod to writing sequence of root assemblies or part of the file specified by use by one label
Standard_EXPORT Standard_Boolean Transfer(const TDF_LabelSequence& theLabelSeq,
const STEPControl_StepModelType theMode = STEPControl_AsIs,
const Standard_CString theIsMulti = 0,
Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& L,
const STEPControl_StepModelType mode = STEPControl_AsIs,
const Standard_CString multi = 0,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc,
const TCollection_AsciiString& filename,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT Standard_Boolean Perform(const Handle(TDocStd_Document)& theDoc,
const TCollection_AsciiString& theFileName,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Transfers a document and writes it to a STEP file
//! Returns True if translation is OK
Standard_EXPORT Standard_Boolean Perform(const Handle(TDocStd_Document)& theDoc,
const Standard_CString theFileName,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT Standard_Boolean Perform (const Handle(TDocStd_Document)& doc,
const Standard_CString filename,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Returns data on external files
//! Returns Null handle if no external files are read
const NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& ExternFiles() const { return myFiles; };
Standard_EXPORT const NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& ExternFiles() const;
//! Returns data on external file by its original label
//! Returns False if no external file with given name is read
Standard_EXPORT Standard_Boolean ExternFile(const TDF_Label& theLabel,
Handle(STEPCAFControl_ExternFile)& theExtFile) const;
Standard_EXPORT Standard_Boolean ExternFile (const TDF_Label& L, Handle(STEPCAFControl_ExternFile)& ef) const;
//! Returns data on external file by its name
//! Returns False if no external file with given name is read
Standard_EXPORT Standard_Boolean ExternFile(const Standard_CString theName,
Handle(STEPCAFControl_ExternFile)& theExtFile) const;
Standard_EXPORT Standard_Boolean ExternFile (const Standard_CString name, Handle(STEPCAFControl_ExternFile)& ef) const;
//! Returns basic reader for root file
STEPControl_Writer& ChangeWriter() { return myWriter; }
Standard_EXPORT STEPControl_Writer& ChangeWriter();
//! Returns basic reader as const
const STEPControl_Writer& Writer() const { return myWriter; }
Standard_EXPORT const STEPControl_Writer& Writer() const;
//! Set ColorMode for indicate write Colors or not.
void SetColorMode(const Standard_Boolean theColorMode) { myColorMode = theColorMode; }
Standard_Boolean GetColorMode() const { return myColorMode; }
Standard_EXPORT void SetColorMode (const Standard_Boolean colormode);
Standard_EXPORT Standard_Boolean GetColorMode() const;
//! Set NameMode for indicate write Name or not.
void SetNameMode(const Standard_Boolean theNameMode) { myNameMode = theNameMode; }
Standard_Boolean GetNameMode() const { return myNameMode; }
Standard_EXPORT void SetNameMode (const Standard_Boolean namemode);
Standard_EXPORT Standard_Boolean GetNameMode() const;
//! Set LayerMode for indicate write Layers or not.
void SetLayerMode(const Standard_Boolean theLayerMode) { myLayerMode = theLayerMode; }
Standard_Boolean GetLayerMode() const { return myLayerMode; }
Standard_EXPORT void SetLayerMode (const Standard_Boolean layermode);
Standard_EXPORT Standard_Boolean GetLayerMode() const;
//! PropsMode for indicate write Validation properties or not.
void SetPropsMode(const Standard_Boolean thePropsMode) { myPropsMode = thePropsMode; }
Standard_Boolean GetPropsMode() const { return myPropsMode; }
Standard_EXPORT void SetPropsMode (const Standard_Boolean propsmode);
Standard_EXPORT Standard_Boolean GetPropsMode() const;
//! Set SHUO mode for indicate write SHUO or not.
void SetSHUOMode(const Standard_Boolean theSHUOMode) { mySHUOMode = theSHUOMode; }
Standard_Boolean GetSHUOMode() const { return mySHUOMode; }
Standard_EXPORT void SetSHUOMode (const Standard_Boolean shuomode);
Standard_EXPORT Standard_Boolean GetSHUOMode() const;
//! Set dimtolmode for indicate write D&GTs or not.
void SetDimTolMode(const Standard_Boolean theDimTolMode) { myGDTMode = theDimTolMode; };
Standard_Boolean GetDimTolMode() const { return myGDTMode; }
Standard_EXPORT void SetDimTolMode (const Standard_Boolean dimtolmode);
Standard_EXPORT Standard_Boolean GetDimTolMode() const;
//! Set dimtolmode for indicate write D&GTs or not.
void SetMaterialMode(const Standard_Boolean theMaterialMode) { myMatMode = theMaterialMode; }
Standard_Boolean GetMaterialMode() const { return myMatMode; }
Standard_EXPORT void SetMaterialMode (const Standard_Boolean matmode);
Standard_EXPORT Standard_Boolean GetMaterialMode() const;
protected:
//! Transfers labels to a STEP model
//! Returns True if translation is OK
//! isExternFile setting from transferExternFiles method
Standard_Boolean transfer(STEPControl_Writer& theWriter,
const TDF_LabelSequence& theLabels,
const STEPControl_StepModelType theMode = STEPControl_AsIs,
const Standard_CString theIsMulti = 0,
const Standard_Boolean isExternFile = Standard_False,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! isExternFile setting from TransferExternFiles method
Standard_EXPORT Standard_Boolean Transfer (STEPControl_Writer& wr,
const TDF_LabelSequence& labels,
const STEPControl_StepModelType mode = STEPControl_AsIs,
const Standard_CString multi = 0,
const Standard_Boolean isExternFile = Standard_False,
const Message_ProgressRange& theProgress = Message_ProgressRange()) ;
//! Parses assembly structure of label L, writes all the simple
//! shapes each to its own file named by name of its label plus
//! prefix
//! Returns shape representing that assembly structure
//! in the form of nested empty compounds (and a sequence of
//! labels which are newly written nodes of this assembly)
TopoDS_Shape transferExternFiles(const TDF_Label& theLabel,
const STEPControl_StepModelType theMode,
TDF_LabelSequence& theLabelSeq,
const Standard_CString thePrefix = "",
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_EXPORT TopoDS_Shape TransferExternFiles (const TDF_Label& L,
const STEPControl_StepModelType mode,
TDF_LabelSequence& Lseq,
const Standard_CString prefix = "",
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Write external references to STEP
Standard_Boolean writeExternRefs(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theLabels) const;
Standard_EXPORT Standard_Boolean WriteExternRefs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
//! Write colors assigned to specified labels, to STEP model
Standard_Boolean writeColors(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theLabels);
Standard_EXPORT Standard_Boolean WriteColors (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
//! Write names assigned to specified labels, to STEP model
Standard_Boolean writeNames(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theLabels) const;
Standard_EXPORT Standard_Boolean WriteNames (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
//! Write D&GTs assigned to specified labels, to STEP model
Standard_Boolean writeDGTs(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theLabels) const;
//! Write D&GTs assigned to specified labels, to STEP model, according AP242
Standard_Boolean writeDGTsAP242(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theLabels);
Standard_EXPORT Standard_Boolean WriteDGTs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
//! Write D&GTs assigned to specified labels, to STEP model, according AP242
Standard_EXPORT Standard_Boolean WriteDGTsAP242 (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
//! Write materials assigned to specified labels, to STEP model
Standard_Boolean writeMaterials(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theLabels) const;
Standard_EXPORT Standard_Boolean WriteMaterials (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
//! Write validation properties assigned to specified labels,
//! to STEP model
Standard_Boolean writeValProps(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theLabels,
const Standard_CString theIsMulti) const;
Standard_EXPORT Standard_Boolean WriteValProps (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels, const Standard_CString multi) const;
//! Write layers assigned to specified labels, to STEP model
Standard_Boolean writeLayers(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theLabels) const;
Standard_EXPORT Standard_Boolean WriteLayers (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
//! Write SHUO assigned to specified component, to STEP model
Standard_Boolean writeSHUOs(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theLabels);
Standard_EXPORT Standard_Boolean WriteSHUOs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
//! Finds length units located in root of label
//! If it exists, initializes local length unit from it
//! Else initializes according to Cascade length unit
void prepareUnit(const TDF_Label& theLabel,
const Handle(StepData_StepModel)& theModel);
Handle(StepRepr_ShapeAspect) writeShapeAspect(const Handle(XSControl_WorkSession)& theWS,
const TDF_Label theLabel,
const TopoDS_Shape theShape,
Handle(StepRepr_RepresentationContext)& theRC,
Handle(StepAP242_GeometricItemSpecificUsage)& theGISU);
void writePresentation(const Handle(XSControl_WorkSession)& theWS,
const TopoDS_Shape& thePresentation,
const Handle(TCollection_HAsciiString)& thePrsName,
const Standard_Boolean theHasSemantic,
const Standard_Boolean theHasPlane,
const gp_Ax2& theAnnotationPlane,
const gp_Pnt& theTextPosition,
const Handle(Standard_Transient) theDimension);
Handle(StepDimTol_Datum) writeDatumAP242(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theShapeL,
const TDF_Label& theDatumL,
const Standard_Boolean isFirstDTarget,
const Handle(StepDimTol_Datum) theWrittenDatum);
void writeToleranceZone(const Handle(XSControl_WorkSession)& theWS,
const Handle(XCAFDimTolObjects_GeomToleranceObject)& theObject,
const Handle(StepDimTol_GeometricTolerance)& theEntity,
const Handle(StepRepr_RepresentationContext)& theRC);
void writeGeomTolerance(const Handle(XSControl_WorkSession)& theWS,
const TDF_LabelSequence& theShapeSeqL,
const TDF_Label& theGeomTolL,
const Handle(StepDimTol_HArray1OfDatumSystemOrReference)& theDatumSystem,
const Handle(StepRepr_RepresentationContext)& theRC);
Standard_EXPORT void prepareUnit(const TDF_Label& theLabel,
const Handle(StepData_StepModel)& theModel);
private:
Standard_EXPORT Handle(StepRepr_ShapeAspect) WriteShapeAspect(const Handle(XSControl_WorkSession) &WS,
const TDF_Label theLabel, const TopoDS_Shape theShape, Handle(StepRepr_RepresentationContext)& theRC,
Handle(StepAP242_GeometricItemSpecificUsage)& theGISU);
Standard_EXPORT void WritePresentation(const Handle(XSControl_WorkSession)& WS,
const TopoDS_Shape& thePresentation,
const Handle(TCollection_HAsciiString)& thePrsName,
const Standard_Boolean hasSemantic,
const Standard_Boolean hasPlane,
const gp_Ax2& theAnnotationPlane,
const gp_Pnt& theTextPosition,
const Handle(Standard_Transient) theDimension);
Standard_EXPORT Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSession)& WS,
const TDF_LabelSequence& theShapeL,
const TDF_Label& theDatumL,
const Standard_Boolean isFirstDTarget,
const Handle(StepDimTol_Datum) theWrittenDatum);
Standard_EXPORT void WriteToleranceZone(const Handle(XSControl_WorkSession) &WS, const Handle(XCAFDimTolObjects_GeomToleranceObject)& theObject,
const Handle(StepDimTol_GeometricTolerance)& theEntity, const Handle(StepRepr_RepresentationContext)& theRC);
Standard_EXPORT void WriteGeomTolerance(const Handle(XSControl_WorkSession)& WS,
const TDF_LabelSequence& theShapeSeqL,
const TDF_Label& theGeomTolL,
const Handle(StepDimTol_HArray1OfDatumSystemOrReference)& theDatumSystem,
const Handle(StepRepr_RepresentationContext)& theRC);
private:
STEPControl_Writer myWriter;
NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myFiles;
TDF_LabelMap myRootLabels;
STEPCAFControl_DataMapOfLabelShape myLabels;
STEPCAFControl_DataMapOfLabelExternFile myLabEF;
STEPCAFControl_DataMapOfLabelShape myPureRefLabels;
Standard_Boolean myColorMode;
Standard_Boolean myNameMode;
Standard_Boolean myLayerMode;
@@ -288,4 +272,7 @@ private:
};
#endif // _STEPCAFControl_Writer_HeaderFile

View File

@@ -869,27 +869,32 @@ Standard_Boolean SelectMgr_Frustum<N>::hasCircleOverlap (const Standard_Real the
const gp_Pnt aCenterProject (aCoefA * aTCenter,
aCoefB * aTCenter,
aCoefC * aTCenter);
if (isDotInside (aCenterProject, aVertices))
{
return true;
}
const Standard_Boolean isCenterInside = isDotInside (aCenterProject, aVertices);
Standard_Boolean isInside = false;
Standard_Boolean isInside = true;
for (Standard_Integer anIdx = aVertices.Lower(); anIdx <= aVertices.Upper(); anIdx++)
{
if (aVertices.Value (anIdx).Distance (aCenterProject) > theRadius)
{
isInside = true;
isInside = false;
break;
}
}
if (theInside != NULL)
{
*theInside = isInside && isCenterInside;
*theInside = false;
}
return theIsFilled
? !isInside || (isCenterInside && isInside)
: isInside && isCenterInside;
if (!theIsFilled && isInside)
{
return false;
}
return isInside;
}
//=======================================================================

View File

@@ -58,33 +58,12 @@ public:
return ZLayerPosition > theOther.ZLayerPosition;
}
// closest object is selected if their depths are not equal within tolerance
if (Abs (Depth - theOther.Depth) > Tolerance + theOther.Tolerance)
// closest object is selected unless difference is within tolerance
if (Abs (Depth - theOther.Depth) > (Tolerance + theOther.Tolerance))
{
return Depth < theOther.Depth;
}
Standard_Real aCos = 1.0;
if (Normal.Modulus() > 0 && theOther.Normal.Modulus() > 0)
{
gp_Dir aNormal (Normal.x(), Normal.y(), Normal.z());
gp_Dir anOtherNormal (theOther.Normal.x(), theOther.Normal.y(), theOther.Normal.z());
aCos = Abs (Cos (aNormal.Angle (anOtherNormal)));
}
Standard_Real aDepth = Depth - Tolerance;
Standard_Real anOtherDepth = theOther.Depth - theOther.Tolerance;
// Comparison depths taking into account tolerances occurs when the surfaces are parallel
// or have the same sensitivity and the angle between them is less than 60 degrees.
if (Abs (aDepth - anOtherDepth) > Precision::Confusion())
{
if ((aCos > 0.5 && Abs (Tolerance - theOther.Tolerance) < Precision::Confusion())
|| Abs (aCos - 1.0) < Precision::Confusion())
{
return aDepth < anOtherDepth;
}
}
// if two objects have similar depth, select the one with higher priority
if (Priority > theOther.Priority)
{

View File

@@ -284,9 +284,9 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(Select3D_SensitiveEnti
aCriterion.NbOwnerMatches = aPrevCriterion->NbOwnerMatches;
if (theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Box)
{
updatePoint3d (aCriterion, aPickResult, theEntity, theInversedTrsf, theMgr);
if (aCriterion.IsCloserDepth (*aPrevCriterion))
{
updatePoint3d (aCriterion, aPickResult, theEntity, theInversedTrsf, theMgr);
*aPrevCriterion = aCriterion;
}
}

View File

@@ -138,7 +138,7 @@ void StepToTopoDS_TranslateShell::Init(const Handle(StepVisual_TessellatedShell)
{
Handle(TransferBRep_ShapeBinder) aBinder
= Handle(TransferBRep_ShapeBinder)::DownCast(aTP->Find(theTSh->TopologicalLink()));
if (!aBinder.IsNull())
if (aBinder.IsNull())
{
aSh = aBinder->Shell();
theHasGeom = Standard_True;

View File

@@ -20,7 +20,6 @@
#include <ViewerTest.hxx>
#include <AIS_AnimationAxisRotation.hxx>
#include <AIS_AnimationCamera.hxx>
#include <AIS_AnimationObject.hxx>
#include <AIS_Axis.hxx>
@@ -7597,11 +7596,6 @@ static Standard_Integer VAnimation (Draw_Interpretor& theDI,
gp_XYZ aLocPnts [2] = { aTrsfs[0].TranslationPart(), aTrsfs[1].TranslationPart() };
Standard_Real aScales [2] = { aTrsfs[0].ScaleFactor(), aTrsfs[1].ScaleFactor() };
Standard_Boolean isTrsfSet = Standard_False;
gp_Ax1 anAxis;
Standard_Real anAngles[2] = { 0.0, 0.0 };
Standard_Boolean isAxisRotationSet = Standard_False;
Standard_Integer aTrsfArgIter = anArgIter + 1;
for (; aTrsfArgIter < theArgNb; ++aTrsfArgIter)
{
@@ -7649,45 +7643,13 @@ static Standard_Integer VAnimation (Draw_Interpretor& theDI,
}
aScales[anIndex] = aScaleStr.RealValue();
}
else if (aTrsfArg == "-axis")
{
isAxisRotationSet = Standard_True;
gp_XYZ anOrigin, aDirection;
if (aTrsfArgIter + 6 >= theArgNb
|| !parseXYZ (theArgVec + aTrsfArgIter + 1, anOrigin)
|| !parseXYZ (theArgVec + aTrsfArgIter + 4, aDirection))
{
Message::SendFail() << "Syntax error at " << aTrsfArg;
return 1;
}
anAxis.SetLocation (anOrigin);
anAxis.SetDirection (aDirection);
aTrsfArgIter += 6;
}
else if (aTrsfArg.StartsWith ("-ang"))
{
isAxisRotationSet = Standard_True;
if (++aTrsfArgIter >= theArgNb)
{
Message::SendFail() << "Syntax error at " << aTrsfArg;
return 1;
}
const TCollection_AsciiString anAngleStr (theArgVec[aTrsfArgIter]);
if (!anAngleStr.IsRealValue (Standard_True))
{
Message::SendFail() << "Syntax error at " << aTrsfArg;
return 1;
}
anAngles[anIndex] = anAngleStr.RealValue();
}
else
{
anArgIter = aTrsfArgIter - 1;
break;
}
}
if (!isTrsfSet && !isAxisRotationSet)
if (!isTrsfSet)
{
Message::SendFail() << "Syntax error at " << anArg;
return 1;
@@ -7696,23 +7658,15 @@ static Standard_Integer VAnimation (Draw_Interpretor& theDI,
{
anArgIter = theArgNb;
}
Handle(AIS_BaseAnimationObject) anObjAnimation;
if (isTrsfSet)
{
aTrsfs[0].SetRotation (aRotQuats[0]);
aTrsfs[1].SetRotation (aRotQuats[1]);
aTrsfs[0].SetTranslationPart (aLocPnts[0]);
aTrsfs[1].SetTranslationPart (aLocPnts[1]);
aTrsfs[0].SetScaleFactor (aScales[0]);
aTrsfs[1].SetScaleFactor (aScales[1]);
anObjAnimation = new AIS_AnimationObject (anAnimation->Name(), aCtx, anObject, aTrsfs[0], aTrsfs[1]);
}
else
{
anObjAnimation = new AIS_AnimationAxisRotation (anAnimation->Name(), aCtx, anObject, anAxis,
anAngles[0] * (M_PI / 180.0), anAngles[1] * (M_PI / 180.0));
}
aTrsfs[0].SetRotation (aRotQuats[0]);
aTrsfs[1].SetRotation (aRotQuats[1]);
aTrsfs[0].SetTranslationPart (aLocPnts[0]);
aTrsfs[1].SetTranslationPart (aLocPnts[1]);
aTrsfs[0].SetScaleFactor (aScales[0]);
aTrsfs[1].SetScaleFactor (aScales[1]);
Handle(AIS_AnimationObject) anObjAnimation = new AIS_AnimationObject (anAnimation->Name(), aCtx, anObject, aTrsfs[0], aTrsfs[1]);
replaceAnimation (aParentAnimation, anAnimation, anObjAnimation);
}
else if (anArg == "-viewtrsf"
@@ -14440,11 +14394,6 @@ Object animation:
-rotX object Orientations pair (quaternions)
-scaleX object Scale factors pair (quaternions)
vanim name -object [-axis OX OY OZ DX DY DZ] [-ang1 A] [-ang2 A]
-axis rotation axis
-ang1 start rotation angle in degrees
-ang2 end rotation angle in degrees
Custom callback:
vanim name -invoke "Command Arg1 Arg2 %Pts %LocalPts %Normalized ArgN"

View File

@@ -51,6 +51,30 @@ bool Vrml_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Read(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool Vrml_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool Vrml_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the Vrml_Provider during reading the file " <<
@@ -94,10 +118,8 @@ bool Vrml_Provider::Read(const TCollection_AsciiString& thePath,
//=======================================================================
bool Vrml_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
(void)theProgress;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(Vrml_ConfigurationNode)))
{
@@ -130,6 +152,30 @@ bool Vrml_Provider::Read(const TCollection_AsciiString& thePath,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Read(thePath, theShape, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool Vrml_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool Vrml_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
(void)theProgress;
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(Vrml_ConfigurationNode)))
{
@@ -225,13 +271,12 @@ bool Vrml_Provider::Read(const TCollection_AsciiString& thePath,
//=======================================================================
bool Vrml_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
return Write(thePath, aDoc, theWS, theProgress);
return Write(thePath, aDoc, theProgress);
}
//=======================================================================

View File

@@ -64,6 +64,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
@@ -86,6 +104,24 @@ public:
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
//! Gets CAD format name of associated provider

View File

@@ -194,63 +194,29 @@ const Handle(VrmlData_WorldInfo)& VrmlData_Scene::WorldInfo() const
//purpose :
//=======================================================================
VrmlData_ErrorStatus VrmlData_Scene::readLine(VrmlData_InBuffer& theBuffer)
VrmlData_ErrorStatus VrmlData_Scene::readLine (VrmlData_InBuffer& theBuffer)
{
VrmlData_ErrorStatus aStatus = VrmlData_StatusOK;
if (theBuffer.Input.eof())
{
return VrmlData_EndOfFile;
}
// Read a line.
theBuffer.Input.getline(theBuffer.Line, sizeof(theBuffer.Line));
// Check the number of read symbols.
// If maximum number is read, process the array of symbols separately
// rolling back the array to the last comma or space symbol.
std::streamsize aNbChars = theBuffer.Input.gcount();
if (theBuffer.Input.rdstate() & std::ios::failbit &&
aNbChars == sizeof(theBuffer.Line) - 1)
{
// Clear the error.
// We will fix it here below.
theBuffer.Input.clear();
size_t anInd = aNbChars - 1;
for (; anInd > 0; anInd--)
{
Standard_Character aChar = theBuffer.Line[anInd];
if (aChar == ',' || aChar == ' ')
{
theBuffer.Line[anInd + 1] = '\0';
break;
aStatus = VrmlData_EndOfFile;
else {
theBuffer.Input.getline (theBuffer.Line, sizeof(theBuffer.Line));
theBuffer.LineCount++;
const int stat = theBuffer.Input.rdstate();
if (stat & std::ios::badbit) {
aStatus = VrmlData_UnrecoverableError;
}
else if (stat & std::ios::failbit) {
if (stat & std::ios::eofbit) {
aStatus = VrmlData_EndOfFile;
}
else {
aStatus = VrmlData_GeneralError;
}
}
if (anInd == 0) // no possible to rolling back
{
return VrmlData_UnrecoverableError;
}
theBuffer.Input.seekg(-(aNbChars - anInd - 1), std::ios::cur);
theBuffer.LinePtr = &theBuffer.Line[0];
theBuffer.IsProcessed = Standard_False;
}
// Check the reading status.
theBuffer.LineCount++;
const int stat = theBuffer.Input.rdstate();
if (stat & std::ios::badbit)
{
aStatus = VrmlData_UnrecoverableError;
}
else if (stat & std::ios::failbit)
{
if (stat & std::ios::eofbit)
{
aStatus = VrmlData_EndOfFile;
}
else
{
aStatus = VrmlData_GeneralError;
}
}
theBuffer.LinePtr = &theBuffer.Line[0];
theBuffer.IsProcessed = Standard_False;
return aStatus;
}

View File

@@ -89,7 +89,7 @@ Standard_Boolean XCAFDoc_ColorTool::IsColor (const TDF_Label& lab) const
//=======================================================================
Standard_Boolean XCAFDoc_ColorTool::GetColor (const TDF_Label& lab,
Quantity_Color& col)
Quantity_Color& col) const
{
Quantity_ColorRGBA aCol;
Standard_Boolean isDone = GetColor(lab, aCol);
@@ -104,8 +104,10 @@ Standard_Boolean XCAFDoc_ColorTool::GetColor (const TDF_Label& lab,
//=======================================================================
Standard_Boolean XCAFDoc_ColorTool::GetColor(const TDF_Label& lab,
Quantity_ColorRGBA& col)
Quantity_ColorRGBA& col) const
{
if (lab.Father() != Label()) return Standard_False;
Handle(XCAFDoc_Color) ColorAttribute;
if (!lab.FindAttribute(XCAFDoc_Color::GetID(), ColorAttribute))
return Standard_False;
@@ -512,7 +514,7 @@ XCAFDoc_ColorTool::XCAFDoc_ColorTool()
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_ColorTool::IsVisible (const TDF_Label& L)
Standard_Boolean XCAFDoc_ColorTool::IsVisible (const TDF_Label& L) const
{
Handle(TDataStd_UAttribute) aUAttr;
return (!L.FindAttribute(XCAFDoc::InvisibleGUID(), aUAttr));

View File

@@ -72,12 +72,12 @@ public:
//! Returns color defined by label lab
//! Returns False if the label is not in colortable
//! or does not define a color
Standard_EXPORT static Standard_Boolean GetColor (const TDF_Label& lab, Quantity_Color& col);
Standard_EXPORT Standard_Boolean GetColor (const TDF_Label& lab, Quantity_Color& col) const;
//! Returns color defined by label lab
//! Returns False if the label is not in colortable
//! or does not define a color
Standard_EXPORT static Standard_Boolean GetColor(const TDF_Label& lab, Quantity_ColorRGBA& col);
Standard_EXPORT Standard_Boolean GetColor(const TDF_Label& lab, Quantity_ColorRGBA& col) const;
//! Finds a color definition in a colortable and returns
//! its label if found
@@ -150,11 +150,11 @@ public:
//! Returns color assigned to <L> as <type>
//! Returns False if no such color is assigned
Standard_EXPORT static Standard_Boolean GetColor (const TDF_Label& L, const XCAFDoc_ColorType type, Quantity_Color& color);
Standard_EXPORT Standard_Boolean GetColor (const TDF_Label& L, const XCAFDoc_ColorType type, Quantity_Color& color);
//! Returns color assigned to <L> as <type>
//! Returns False if no such color is assigned
Standard_EXPORT static Standard_Boolean GetColor(const TDF_Label& L, const XCAFDoc_ColorType type, Quantity_ColorRGBA& color);
Standard_EXPORT Standard_Boolean GetColor(const TDF_Label& L, const XCAFDoc_ColorType type, Quantity_ColorRGBA& color);
//! Sets a link with GUID defined by <type> (see
//! XCAFDoc::ColorRefGUID()) from label <L> to color
@@ -198,7 +198,7 @@ public:
Standard_EXPORT Standard_Boolean GetColor(const TopoDS_Shape& S, const XCAFDoc_ColorType type, Quantity_ColorRGBA& color);
//! Return TRUE if object on this label is visible, FALSE if invisible.
Standard_EXPORT static Standard_Boolean IsVisible (const TDF_Label& L);
Standard_EXPORT Standard_Boolean IsVisible (const TDF_Label& L) const;
//! Set the visibility of object on label. Do nothing if there no any object.
//! Set UAttribute with corresponding GUID.

View File

@@ -503,7 +503,7 @@ TDF_Label XCAFDoc_DimTolTool::SetDimTol(const TDF_Label& L,
Standard_Boolean XCAFDoc_DimTolTool::GetRefShapeLabel(const TDF_Label& theL,
TDF_LabelSequence& theShapeLFirst,
TDF_LabelSequence& theShapeLSecond)
TDF_LabelSequence& theShapeLSecond) const
{
theShapeLFirst.Clear();
theShapeLSecond.Clear();
@@ -855,7 +855,7 @@ Standard_Boolean XCAFDoc_DimTolTool::GetDatum(const TDF_Label& theDatumL,
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::GetDatumOfTolerLabels(const TDF_Label& theDimTolL,
TDF_LabelSequence& theDatums)
TDF_LabelSequence& theDatums) const
{
Handle(XCAFDoc_GraphNode) aNode;
if( !theDimTolL.FindAttribute(XCAFDoc::DatumTolRefGUID(),aNode) )
@@ -874,7 +874,7 @@ Standard_Boolean XCAFDoc_DimTolTool::GetDatumOfTolerLabels(const TDF_Label& theD
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::GetDatumWithObjectOfTolerLabels(const TDF_Label& theDimTolL,
TDF_LabelSequence& theDatums)
TDF_LabelSequence& theDatums) const
{
Handle(XCAFDoc_GraphNode) aNode;
if( !theDimTolL.FindAttribute(XCAFDoc::DatumTolRefGUID(),aNode) )

View File

@@ -155,9 +155,9 @@ public:
//! Gets all shape labels referred by theL label of the GD&T table.
//! Returns False if there are no shape labels added to the sequences.
Standard_EXPORT static Standard_Boolean GetRefShapeLabel (const TDF_Label& theL,
TDF_LabelSequence& theShapeLFirst,
TDF_LabelSequence& theShapeLSecond);
Standard_EXPORT Standard_Boolean GetRefShapeLabel (const TDF_Label& theL,
TDF_LabelSequence& theShapeLFirst,
TDF_LabelSequence& theShapeLSecond) const;
//! Returns dimension tolerance assigned to theDimTolL label.
//! Returns False if no such dimension tolerance is assigned.
@@ -215,12 +215,12 @@ public:
Handle(TCollection_HAsciiString)& theIdentification) const;
//! Returns all Datum labels defined for theDimTolL label.
Standard_EXPORT static Standard_Boolean GetDatumOfTolerLabels (const TDF_Label& theDimTolL,
TDF_LabelSequence& theDatums);
Standard_EXPORT Standard_Boolean GetDatumOfTolerLabels (const TDF_Label& theDimTolL,
TDF_LabelSequence& theDatums) const;
//! Returns all Datum labels with XCAFDimTolObjects_DatumObject defined for label theDimTolL.
Standard_EXPORT static Standard_Boolean GetDatumWithObjectOfTolerLabels (const TDF_Label& theDimTolL,
TDF_LabelSequence& theDatums);
Standard_EXPORT Standard_Boolean GetDatumWithObjectOfTolerLabels (const TDF_Label& theDimTolL,
TDF_LabelSequence& theDatums) const;
//! Returns all GeomToleranses labels defined for theDatumL label.
Standard_EXPORT Standard_Boolean GetTolerOfDatumLabels (const TDF_Label& theDatumL,

View File

@@ -416,20 +416,20 @@ Handle(TColStd_HSequenceOfExtendedString) XCAFDoc_LayerTool::GetLayers(const TDF
//function : GetShapesOfLayer
//purpose :
//=======================================================================
void XCAFDoc_LayerTool::GetShapesOfLayer(const TDF_Label& theLayerL,
TDF_LabelSequence& theShLabels)
void XCAFDoc_LayerTool::GetShapesOfLayer(const TDF_Label& layerL,
TDF_LabelSequence& ShLabels) const
{
theShLabels.Clear();
ShLabels.Clear();
Handle(XCAFDoc_GraphNode) aGNode;
if (theLayerL.FindAttribute(XCAFDoc::LayerRefGUID(), aGNode))
{
for (Standard_Integer aChildInd = 1; aChildInd <= aGNode->NbChildren(); aChildInd++)
{
theShLabels.Append(aGNode->GetChild(aChildInd)->Label());
if ( layerL.FindAttribute( XCAFDoc::LayerRefGUID(), aGNode) ) {
for (Standard_Integer i = 1; i <= aGNode->NbChildren(); i++) {
ShLabels.Append( aGNode->GetChild(i)->Label() );
}
}
}
//=======================================================================
//function : IsVisible
//purpose :

View File

@@ -135,7 +135,7 @@ public:
Standard_EXPORT Handle(TColStd_HSequenceOfExtendedString) GetLayers (const TDF_Label& L);
//! Return sequanese of shape labels that assigned with layers to <ShLabels>.
Standard_EXPORT static void GetShapesOfLayer (const TDF_Label& theLayerL, TDF_LabelSequence& theShLabels);
Standard_EXPORT void GetShapesOfLayer (const TDF_Label& layerL, TDF_LabelSequence& ShLabels) const;
//! Return TRUE if layer is visible, FALSE if invisible.
Standard_EXPORT Standard_Boolean IsVisible (const TDF_Label& layerL) const;

View File

@@ -184,7 +184,7 @@ Standard_Boolean XCAFDoc_MaterialTool::GetMaterial(const TDF_Label& MatL,
Handle(TCollection_HAsciiString)& aDescription,
Standard_Real& aDensity,
Handle(TCollection_HAsciiString)& aDensName,
Handle(TCollection_HAsciiString)& aDensValType)
Handle(TCollection_HAsciiString)& aDensValType) const
{
Handle(XCAFDoc_Material) MatAttr;
if(!MatL.FindAttribute(XCAFDoc_Material::GetID(),MatAttr)) {

View File

@@ -76,7 +76,7 @@ public:
//! Returns Material assigned to <MatL>
//! Returns False if no such Material is assigned
Standard_EXPORT static Standard_Boolean GetMaterial (const TDF_Label& MatL, Handle(TCollection_HAsciiString)& aName, Handle(TCollection_HAsciiString)& aDescription, Standard_Real& aDensity, Handle(TCollection_HAsciiString)& aDensName, Handle(TCollection_HAsciiString)& aDensValType);
Standard_EXPORT Standard_Boolean GetMaterial (const TDF_Label& MatL, Handle(TCollection_HAsciiString)& aName, Handle(TCollection_HAsciiString)& aDescription, Standard_Real& aDensity, Handle(TCollection_HAsciiString)& aDensName, Handle(TCollection_HAsciiString)& aDensValType) const;
//! Find referred material and return density from it
//! if no material --> return 0

View File

@@ -353,47 +353,6 @@ TopoDS_Shape XCAFDoc_ShapeTool::GetShape(const TDF_Label& L)
return aShape;
}
//=======================================================================
//function : GetShapes
//purpose :
//=======================================================================
TopoDS_Shape XCAFDoc_ShapeTool::GetOneShape(const TDF_LabelSequence& theLabels)
{
TopoDS_Shape aShape;
if (theLabels.Length() == 1)
{
return GetShape(theLabels.Value(1));
}
TopoDS_Compound aCompound;
BRep_Builder aBuilder;
aBuilder.MakeCompound(aCompound);
for (TDF_LabelSequence::Iterator anIt(theLabels); anIt.More(); anIt.Next())
{
TopoDS_Shape aFreeShape;
if (!GetShape(anIt.Value(), aFreeShape))
{
continue;
}
aBuilder.Add(aCompound, aFreeShape);
}
if (aCompound.NbChildren() > 0)
{
aShape = aCompound;
}
return aShape;
}
//=======================================================================
//function : GetOneShape
//purpose :
//=======================================================================
TopoDS_Shape XCAFDoc_ShapeTool::GetOneShape() const
{
TDF_LabelSequence aLabels;
GetFreeShapes(aLabels);
return GetOneShape(aLabels);
}
//=======================================================================
//function : NewShape
//purpose :

View File

@@ -196,15 +196,6 @@ public:
//! For component, returns new shape with correct location
//! Returns Null shape if label does not contain shape
Standard_EXPORT static TopoDS_Shape GetShape (const TDF_Label& L);
//! Gets shape from a sequence of shape's labels
//! @param[in] theLabels a sequence of labels to get shapes from
//! @return original shape in case of one label and a compound of shapes in case of more
Standard_EXPORT static TopoDS_Shape GetOneShape(const TDF_LabelSequence& theLabels);
//! Gets shape from a sequence of all top-level shapes which are free
//! @return original shape in case of one label and a compound of shapes in case of more
Standard_EXPORT TopoDS_Shape GetOneShape() const;
//! Creates new (empty) top-level shape.
//! Initially it holds empty TopoDS_Compound

View File

@@ -79,10 +79,13 @@ const Handle(XCAFDoc_ShapeTool)& XCAFDoc_VisMaterialTool::ShapeTool()
//function : GetMaterial
//purpose :
//=======================================================================
Handle(XCAFDoc_VisMaterial) XCAFDoc_VisMaterialTool::GetMaterial(const TDF_Label& theMatLabel)
Handle(XCAFDoc_VisMaterial) XCAFDoc_VisMaterialTool::GetMaterial (const TDF_Label& theMatLabel) const
{
Handle(XCAFDoc_VisMaterial) aMatAttrib;
theMatLabel.FindAttribute(XCAFDoc_VisMaterial::GetID(), aMatAttrib);
if (theMatLabel.Father() == Label())
{
theMatLabel.FindAttribute (XCAFDoc_VisMaterial::GetID(), aMatAttrib);
}
return aMatAttrib;
}
@@ -211,7 +214,8 @@ Standard_Boolean XCAFDoc_VisMaterialTool::GetShapeMaterial (const TDF_Label& the
Handle(XCAFDoc_VisMaterial) XCAFDoc_VisMaterialTool::GetShapeMaterial (const TDF_Label& theShapeLabel)
{
TDF_Label aMatLabel;
return GetShapeMaterial (theShapeLabel, aMatLabel)
return Label().HasChild() // do not waste time on shape attributes if materials map is empty
&& GetShapeMaterial (theShapeLabel, aMatLabel)
? GetMaterial (aMatLabel)
: Handle(XCAFDoc_VisMaterial)();
}

View File

@@ -56,7 +56,7 @@ public:
Standard_Boolean IsMaterial (const TDF_Label& theLabel) const { return !GetMaterial (theLabel).IsNull(); }
//! Returns Material defined by specified Label, or NULL if the label is not in Material Table.
Standard_EXPORT static Handle(XCAFDoc_VisMaterial) GetMaterial (const TDF_Label& theMatLabel);
Standard_EXPORT Handle(XCAFDoc_VisMaterial) GetMaterial (const TDF_Label& theMatLabel) const;
//! Adds Material definition to a Material Table and returns its Label.
Standard_EXPORT TDF_Label AddMaterial (const Handle(XCAFDoc_VisMaterial)& theMat,
@@ -88,7 +88,7 @@ public:
Standard_EXPORT static Standard_Boolean GetShapeMaterial (const TDF_Label& theShapeLabel, TDF_Label& theMaterialLabel);
//! Returns material assigned to the shape label.
Standard_EXPORT static Handle(XCAFDoc_VisMaterial) GetShapeMaterial (const TDF_Label& theShapeLabel);
Standard_EXPORT Handle(XCAFDoc_VisMaterial) GetShapeMaterial (const TDF_Label& theShapeLabel);
//! Sets a link with GUID XCAFDoc::VisMaterialRefGUID() from shape label to material label.
//! @param theShape [in] shape

File diff suppressed because it is too large Load Diff

View File

@@ -509,37 +509,40 @@ static Standard_Integer getFreeShapes (Draw_Interpretor& di, Standard_Integer ar
return 0;
}
//=======================================================================
//function : getOneShape
//purpose :
//=======================================================================
static Standard_Integer getOneShape (Draw_Interpretor& theDI,
Standard_Integer theNbArgs,
const char** theArgVec)
static Standard_Integer getOneShape (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if ( theNbArgs !=3 )
{
theDI <<"Use: "<< theArgVec[0]<<" shape DocName \n";
if (argc!=3) {
di<<"Use: "<<argv[0]<<" shape DocName \n";
return 1;
}
Handle(TDocStd_Document) aDoc;
DDocStd::GetDocument(theArgVec[2], aDoc);
if ( aDoc.IsNull() )
{
theDI << "Error: " << theArgVec[2] << " is not a document\n";
return 1;
}
Handle(TDocStd_Document) Doc;
DDocStd::GetDocument(argv[2], Doc);
if ( Doc.IsNull() ) { di << argv[2] << " is not a document\n"; return 1; }
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
TopoDS_Shape aShape = aSTool->GetOneShape();
if (aShape.IsNull())
{
theDI << "Error: Document " << theArgVec[2] << " contain no shapes\n";
return 1;
TDF_LabelSequence Labels;
Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
STool->GetFreeShapes(Labels);
if ( Labels.Length() <=0 ) {
di << "Document " << argv[2] << " contain no shapes\n";
return 0;
}
DBRep::Set (theArgVec[1], aShape);
theDI << theArgVec[1];
if ( Labels.Length() ==1 ) {
TopoDS_Shape S = STool->GetShape ( Labels.Value(1) );
DBRep::Set ( argv[1], S );
}
else {
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound ( C );
for ( Standard_Integer i = 1; i<= Labels.Length(); i++) {
TopoDS_Shape S = STool->GetShape ( Labels.Value(i) );
B.Add ( C, S );
}
DBRep::Set ( argv[1], C );
}
di << argv[1];
return 0;
}

File diff suppressed because it is too large Load Diff

14
tests/bugs/mesh/bug31586 Normal file
View File

@@ -0,0 +1,14 @@
puts "========"
puts "0031586: BRepMesh hangs up"
puts "========"
puts ""
puts "TODO OCC31586 All: Not connected mesh inside face"
restore [locate_data_file bug31586.brep] result
incmesh result 0.022627417117969499
checkview -display result -3d -path ${imagedir}/${test_image}.png
tricheck result

View File

@@ -1,24 +0,0 @@
puts "========"
puts "0033315: Mesh - BRepMesh_IncrementalMesh takes forever to finish (ends up with system memory, etc)"
puts "========"
puts ""
restore [locate_data_file bug33315.brep] result
incmesh result 3.5 -a 20
checktrinfo result -tri 1516 -nod 1118
vinit
vsetdispmode 1
vdefaults -autoTriang 0
vdisplay result
vfit
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
set log [tricheck result]
if { [llength $log] != 0 } {
puts "Error : Invalid mesh"
} else {
puts "Mesh is OK"
}

View File

@@ -1,4 +1,4 @@
puts "TODO OCC26556 ALL: ERROR. Mixed connectivity of faces."
puts "TODO OCC26556 ALL: ERROR. offsetperform operation not done."
puts "============"
puts "OCC5805"
@@ -20,7 +20,6 @@ if { [catch { offsetshape result a -1 a_6 } catch_result] } {
puts "Faulty ${BugNumber} : offsetshape is wrong"
}
if { [isdraw result] } {
checkmaxtol result -min_tol 1.
checkprops result -s 1185.03
@@ -28,4 +27,3 @@ checkshape result
checknbshapes result -vertex 10 -edge 15 -wire 7 -face 7 -shell 1 -solid 1 -compsolid 0 -compound 0 -shape 41
checkview -display result -2d -path ${imagedir}/${test_image}.png
}

View File

@@ -1,4 +1,6 @@
puts "TODO OCC25925 ALL: ERROR. Mixed connectivity of faces."
puts "TODO OCC25925 ALL: ERROR. offsetperform operation not done."
puts "TODO OCC25925 ALL: Tcl Exception:"
puts "TODO OCC25925 ALL: TEST INCOMPLETE"
puts "============"
puts "OCC5805"
@@ -23,7 +25,6 @@ if { [catch { offsetperform result } catch_result] } {
puts "Faulty ${BugNumber} : offsetshape is wrong"
}
if { [isdraw result] } {
checkmaxtol result -min_tol 1.
checkprops result -s 1185.03
@@ -31,4 +32,3 @@ checkshape result
checknbshapes result -vertex 10 -edge 15 -wire 7 -face 7 -shell 1 -solid 1 -compsolid 0 -compound 0 -shape 41
checkview -display result -2d -path ${imagedir}/${test_image}.png
}

View File

@@ -1,5 +1,3 @@
puts "TODO OCC25925 ALL: ERROR. Mixed connectivity of faces."
puts "============"
puts "OCC5805"
puts "============"
@@ -23,7 +21,6 @@ if { [catch { offsetperform result } catch_result] } {
puts "Faulty ${BugNumber} : offsetshape is wrong"
}
if { [isdraw result] } {
checkmaxtol result -min_tol 1.
checkprops result -s 876.584
@@ -31,5 +28,3 @@ checkshape result
checknbshapes result -vertex 10 -edge 15 -wire 7 -face 7 -shell 1 -solid 1 -compsolid 0 -compound 0 -shape 41
checkview -display result -2d -path ${imagedir}/${test_image}.png
}

View File

@@ -1,5 +1,3 @@
puts "TODO OCC25925 ALL: ERROR. Mixed connectivity of faces."
puts "============"
puts "OCC5805"
puts "============"
@@ -18,12 +16,9 @@ if { [catch { offsetshape result a -1 } catch_result] } {
puts "Faulty ${BugNumber} : offsetshape is wrong"
}
if { [isdraw result] } {
checkmaxtol result -min_tol 1.
checkprops result -s 876.584
checkshape result
checknbshapes result -vertex 10 -edge 15 -wire 7 -face 7 -shell 1 -solid 1 -compsolid 0 -compound 0 -shape 41
checkview -display result -2d -path ${imagedir}/${test_image}.png
}

View File

@@ -1,18 +0,0 @@
puts "================================"
puts "OCC33113: Modeling Algorithms - BRepFilletAPI_MakeFillet::Build SIGSEGV"
puts "================================"
restore [locate_data_file bug33113.brep] sh
explode sh e
copy sh_4 e
explode sh So
copy sh_1 s
fillet res s 0.1 e
checkshape res
checkview -display res -3d -path ${imagedir}/${test_image}.png

View File

@@ -1,13 +0,0 @@
puts "============"
puts "0033227: Modeling Algorithm - BOPAlgo_BuilderSolid generates incomplete result"
puts "============"
puts ""
restore [locate_data_file bug33227.brep] s
bopbsolid r s
compound r_2 r_3 res
checknbshapes res -shell 6 -solid 2
checkprops res -v 3.33117e+07
checkview -display res -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,13 +0,0 @@
puts "============"
puts "0033247: Modeling Algorithms - BOP report small edges problem and produce empty result"
puts "============"
puts ""
restore [locate_data_file bug33247_object.brep] a
restore [locate_data_file bug33247_tool.brep] b
bcommon r a b
checknbshapes r -vertex 98 -edge 131 -wire 35 -face 26
checkprops r -s 157.39
checkview -display r -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,11 +0,0 @@
puts "REQUIRED ALL: Algorithm has failed"
puts "========================"
puts "0033306: Modeling Algorithm - Crash in TrimEdge() method"
puts "========================"
puts ""
restore [locate_data_file bug33306_1.brep] w1
restore [locate_data_file bug33306_2.brep] w2
thrusections res 0 0 w1 w2

View File

@@ -1,11 +0,0 @@
puts "========================"
puts "0033311: Modeling Algorithm - No results of thrusection algorithm"
puts "========================"
puts ""
restore [locate_data_file bug33311_1.brep] w1
restore [locate_data_file bug33311_2.brep] w2
thrusections res 0 0 w1 w2
checkview -display res -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,9 +0,0 @@
puts "==========================================================="
puts "0033304: Modeling Data - Floating point signal when converting a B-spline curve to analytical form"
puts "==========================================================="
puts "REQUIRED ALL: Conversion failed"
binrestore [locate_data_file bug33304_bspl_curv.bbrep] a
mkcurve c a
tocanon r c

View File

@@ -1,11 +0,0 @@
puts "==================================================="
puts "0033307: Data Exchange, Step Import - Crash after reading empty edge loop"
puts "==================================================="
puts ""
pload XDE OCAF
Close D -silent
ReadStep D [locate_data_file "bug33307.stp"]
Close D

View File

@@ -1,32 +0,0 @@
puts "========================"
puts "0033317: Data Exchange, Step Export - Ignoring color attached to the reference shape label"
puts "========================"
pload OCAF
Close D -silent
Close D1 -silent
set TempFilename ${imagedir}/${casename}_temp.stp
# Open document
XOpen [locate_data_file bug33317_solids_7_7_0.xml] D
# Get colors
set colors_old [XGetShapeColor D 0:1:1:1 generic]
# Write to STEP
WriteStep D ${TempFilename}
# Read and check
ReadStep D1 ${TempFilename}
set colors_new [XGetShapeColor D1 0:1:1:1:1 generic]
if { [string equal ${colors_new} ${colors_old}] == -1 } {
puts "ERROR: OCC33317 is reproduced while STEP export."
}
# Clear temp file
file delete -force $TempFilename
Close D
Close D1

View File

@@ -1,16 +0,0 @@
puts "======="
puts "0030828: Data Exchange - The commands getting shapes from XCAF document should be available in C++"
puts "======="
pload OCAF
XNewDoc D
box b1 10 10 10
XAddShape D b1 1
XGetOneShape b D
checknbshapes b -shape 34
box b2 10 10 10
ttranslate b2 20 0 0
XAddShape D b2 1
XGetOneShape c D
checknbshapes c -shape 69 -compound 1
Close D -silent

View File

@@ -1,6 +1,6 @@
# !!!! This file is generated automatically, do not edit manually! See end script
puts "TODO CR00000 ALL: Error: First - file was not read - exception "
puts "TODO CR00000 ALL: Error : Here is reading problem"
puts "TODO CR00000 ALL: Error: STEPCAFControl_Provider"
puts "TODO CR23096 ALL: Error: First - file was not read - exception "
puts "TODO CR23096 ALL: Error : Here is reading problem"
set filename tr9_r0301-pe-adjusted.stp

Some files were not shown because too many files have changed in this diff Show More