mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Compare commits
2 Commits
V7_8_1
...
CR0-winwer
Author | SHA1 | Date | |
---|---|---|---|
|
f07607c16b | ||
|
8d604081fe |
@@ -2,6 +2,6 @@ FoundationClasses TKernel TKMath
|
||||
ModelingData TKG2d TKG3d TKGeomBase TKBRep
|
||||
ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffset TKFeat TKMesh TKXMesh TKShHealing
|
||||
Visualization TKService TKV3d TKOpenGl TKMeshVS TKIVtk TKD3DHost
|
||||
ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd FWOSPlugin TKTObj TKBinTObj TKXmlTObj TKVCAF
|
||||
ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd TKTObj TKBinTObj TKXmlTObj TKVCAF
|
||||
DataExchange TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF
|
||||
Draw TKDraw TKTopTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE
|
||||
|
@@ -1247,4 +1247,19 @@ For example, in the wire in the image we want to recuperate the edges in the ord
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@subsection occt_modat_5_6 Storage of shapes
|
||||
|
||||
**BRepTools** and **BinTools** packages contain methods *Read* and *Write* allowing to read and write a Shape to/from a stream or a file.
|
||||
The methods provided by **BRepTools** package use ASCII storage format; **BinTools** package use binary format.
|
||||
Each of these methods has two arguments:
|
||||
- a *TopoDS_Shape* object to be read/written;
|
||||
- a stream object or a file name to read from/write to.
|
||||
|
||||
The following sample code reads a shape from ASCII file and writes it to a binary one:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
|
||||
TopoDS_Shape aShape;
|
||||
if (BRepTools::Read (aShape, "source_file.txt")) {
|
||||
BinTools::Write (aShape, "result_file.bin");
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@@ -15,7 +15,9 @@
|
||||
|
||||
|
||||
#include <BinTools.hxx>
|
||||
#include <BinTools_ShapeSet.hxx>
|
||||
#include <FSD_FileHeader.hxx>
|
||||
#include <OSD_OpenFile.hxx>
|
||||
#include <Storage_StreamTypeMismatchError.hxx>
|
||||
|
||||
//=======================================================================
|
||||
@@ -129,3 +131,64 @@ Standard_IStream& BinTools::GetBool(Standard_IStream& IS, Standard_Boolean& aVal
|
||||
aValue = (Standard_Boolean)IS.get();
|
||||
return IS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools::Write (const TopoDS_Shape& theShape, Standard_OStream& theStream)
|
||||
{
|
||||
BinTools_ShapeSet aShapeSet(Standard_True);
|
||||
aShapeSet.SetFormatNb (3);
|
||||
aShapeSet.Add (theShape);
|
||||
aShapeSet.Write (theStream);
|
||||
aShapeSet.Write (theShape, theStream);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BinTools::Read (TopoDS_Shape& theShape, Standard_IStream& theStream)
|
||||
{
|
||||
BinTools_ShapeSet aShapeSet(Standard_True);
|
||||
aShapeSet.Read (theStream);
|
||||
aShapeSet.Read (theShape, theStream, aShapeSet.NbShapes());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BinTools::Write (const TopoDS_Shape& theShape, const Standard_CString theFile)
|
||||
{
|
||||
ofstream aStream;
|
||||
aStream.precision (15);
|
||||
OSD_OpenStream (aStream, theFile, ios::out | ios::binary);
|
||||
if (!aStream.good())
|
||||
return Standard_False;
|
||||
|
||||
Write (theShape, aStream);
|
||||
aStream.close();
|
||||
return aStream.good();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BinTools::Read (TopoDS_Shape& theShape, const Standard_CString theFile)
|
||||
{
|
||||
filebuf aBuf;
|
||||
OSD_OpenFileBuf (aBuf, theFile, ios::in | ios::binary);
|
||||
if (!aBuf.is_open())
|
||||
return Standard_False;
|
||||
|
||||
Standard_IStream aStream (&aBuf);
|
||||
Read (theShape, aStream);
|
||||
return aStream.good();
|
||||
}
|
||||
|
@@ -20,12 +20,14 @@
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_ExtCharacter.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
class BinTools_ShapeSet;
|
||||
class BinTools_Curve2dSet;
|
||||
class BinTools_CurveSet;
|
||||
@@ -56,9 +58,18 @@ public:
|
||||
Standard_EXPORT static Standard_IStream& GetBool (Standard_IStream& IS, Standard_Boolean& theValue);
|
||||
|
||||
Standard_EXPORT static Standard_IStream& GetExtChar (Standard_IStream& IS, Standard_ExtCharacter& theValue);
|
||||
|
||||
|
||||
|
||||
|
||||
//! Writes <theShape> on <theStream> in binary format.
|
||||
Standard_EXPORT static void Write (const TopoDS_Shape& theShape, Standard_OStream& theStream);
|
||||
|
||||
//! Reads a shape from <theStream> and returns it in <theShape>.
|
||||
Standard_EXPORT static void Read (TopoDS_Shape& theShape, Standard_IStream& theStream);
|
||||
|
||||
//! Writes <theShape> in <theFile>.
|
||||
Standard_EXPORT static Standard_Boolean Write (const TopoDS_Shape& theShape, const Standard_CString theFile);
|
||||
|
||||
//! Reads a shape from <theFile> and returns it in <theShape>.
|
||||
Standard_EXPORT static Standard_Boolean Read (TopoDS_Shape& theShape, const Standard_CString theFile);
|
||||
|
||||
protected:
|
||||
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRepTools_ShapeSet.hxx>
|
||||
#include <BRepTools_WireExplorer.hxx>
|
||||
#include <BinTools.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#include <DBRep_DrawableShape.hxx>
|
||||
#include <Draw.hxx>
|
||||
@@ -1274,6 +1275,51 @@ static Standard_Integer XProgress (Draw_Interpretor& di, Standard_Integer argc,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// binsave
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer binsave(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n <= 2) return 1;
|
||||
|
||||
TopoDS_Shape aShape = DBRep::Get (a[1]);
|
||||
if (aShape.IsNull())
|
||||
{
|
||||
di << a[1] << " is not a shape";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!BinTools::Write (aShape, a[2]))
|
||||
{
|
||||
di << "Cannot write to the file " << a[2];
|
||||
return 1;
|
||||
}
|
||||
|
||||
di << a[1];
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// binrestore
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer binrestore(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n <= 2) return 1;
|
||||
|
||||
TopoDS_Shape aShape;
|
||||
if (!BinTools::Read (aShape, a[1]))
|
||||
{
|
||||
di << "Cannot read from the file " << a[1];
|
||||
return 1;
|
||||
}
|
||||
|
||||
DBRep::Set (a[2], aShape);
|
||||
di << a[2];
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BasicCommands
|
||||
//purpose :
|
||||
@@ -1326,6 +1372,13 @@ void DBRep::BasicCommands(Draw_Interpretor& theCommands)
|
||||
|
||||
// Add command for DRAW-specific ProgressIndicator
|
||||
theCommands.Add ( "XProgress","XProgress [+|-t] [+|-g]: switch on/off textual and graphical mode of Progress Indicator",XProgress,"DE: General");
|
||||
|
||||
theCommands.Add("binsave", "binsave shape filename\n"
|
||||
"\t\tsave the shape in the binary format file",
|
||||
__FILE__, binsave, g);
|
||||
theCommands.Add("binrestore", "binrestore filename shape\n"
|
||||
"\t\trestore the shape from the binary format file",
|
||||
__FILE__, binrestore, g);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -721,7 +721,7 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
|
||||
|
||||
AddAPoint(line,previousPoint);
|
||||
//
|
||||
IntWalk_StatusDeflection Status = IntWalk_OK;
|
||||
IntWalk_StatusDeflection Status = IntWalk_OK, aPrevStatus = IntWalk_OK;
|
||||
Standard_Boolean NoTestDeflection = Standard_False;
|
||||
Standard_Real SvParam[4], f;
|
||||
Standard_Integer LevelOfEmptyInmyIntersectionOn2S=0;
|
||||
@@ -736,6 +736,8 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
|
||||
Arrive = Standard_False;
|
||||
while(!Arrive) //010
|
||||
{
|
||||
aPrevStatus = Status;
|
||||
|
||||
LevelOfIterWithoutAppend++;
|
||||
if(LevelOfIterWithoutAppend>20)
|
||||
{
|
||||
@@ -1126,7 +1128,13 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep,
|
||||
Param(3)=SvParam[2];
|
||||
Param(4)=SvParam[3];
|
||||
|
||||
LevelOfIterWithoutAppend = 0;
|
||||
// In order to avoid cyclic changes
|
||||
// (PasTropGrand --> Decrease step -->
|
||||
// StepTooSmall --> Increase step --> PasTropGrand...)
|
||||
// nullify LevelOfIterWithoutAppend only if the condition
|
||||
// is satisfied:
|
||||
if (aPrevStatus != IntWalk_PasTropGrand)
|
||||
LevelOfIterWithoutAppend = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -2815,7 +2823,7 @@ IntWalk_StatusDeflection IntWalk_PWalking::TestDeflection(const IntImp_ConstIso
|
||||
SquareDistance(CurrentPoint.Value());
|
||||
|
||||
|
||||
if (aSqDist < tolconf*tolconf) {
|
||||
if (aSqDist < Precision::SquareConfusion()) {
|
||||
pasInit[0] = Max(pasInit[0], 5.0*ResoU1);
|
||||
pasInit[1] = Max(pasInit[1], 5.0*ResoV1);
|
||||
pasInit[2] = Max(pasInit[2], 5.0*ResoU2);
|
||||
|
@@ -3,4 +3,4 @@ tscale s 0 0 0 SCALE
|
||||
explode s E
|
||||
blend result s SCALE*2 s_5
|
||||
|
||||
checkprops result -s 1.65391e+08 -eps 0.1
|
||||
checkprops result -s 1.65391e+08
|
||||
|
@@ -1,10 +1,8 @@
|
||||
puts "TODO #22911 ALL: Error : The area of result shape is"
|
||||
|
||||
restore [locate_data_file a350] a
|
||||
restore [locate_data_file b350] b
|
||||
|
||||
bop a b
|
||||
bopfuse result
|
||||
|
||||
checkprops result -s 0
|
||||
checkprops result -s 120.576
|
||||
checkview -display result -2d -otherwise { a b } -s -path ${imagedir}/${test_image}.png
|
||||
|
21
tests/bugs/modalg_6/bug28492_1
Normal file
21
tests/bugs/modalg_6/bug28492_1
Normal file
@@ -0,0 +1,21 @@
|
||||
puts "========"
|
||||
puts "OCC28492"
|
||||
puts "========"
|
||||
puts ""
|
||||
##########################################
|
||||
## Boolean common does not produce expected result
|
||||
##########################################
|
||||
|
||||
restore [locate_data_file bug28492_case1.brep] a
|
||||
explode a
|
||||
bcommon result a_1 a_2
|
||||
|
||||
checknbshapes result -wire 2 -face 1 -t
|
||||
checkprops result -s 1882.29
|
||||
checkshape result
|
||||
|
||||
if {! [regexp "to be valid for BOP" [bopargcheck result] ] } {
|
||||
puts "Error: bopargcheck failed"
|
||||
}
|
||||
|
||||
checkview -display result -2d -path ${imagedir}/${test_image}.png
|
21
tests/bugs/modalg_6/bug28492_2
Normal file
21
tests/bugs/modalg_6/bug28492_2
Normal file
@@ -0,0 +1,21 @@
|
||||
puts "========"
|
||||
puts "OCC28492"
|
||||
puts "========"
|
||||
puts ""
|
||||
##########################################
|
||||
## Boolean common does not produce expected result
|
||||
##########################################
|
||||
|
||||
restore [locate_data_file bug28492_case2.brep] a
|
||||
explode a
|
||||
bcommon result a_1 a_2
|
||||
|
||||
checknbshapes result -wire 1 -face 1 -t
|
||||
checkprops result -s 77.8077
|
||||
checkshape result
|
||||
|
||||
if {! [regexp "to be valid for BOP" [bopargcheck result] ] } {
|
||||
puts "Error: bopargcheck failed"
|
||||
}
|
||||
|
||||
checkview -display result -2d -path ${imagedir}/${test_image}.png
|
@@ -4,5 +4,7 @@ set chamf_dist_angle [list "0.01 30" "0.008 30" "0.01 60" "0.015 60"
|
||||
set chamf_dist_dist [list "0.01 0.006" "0.008 0.006" "0.01 0.012" "0.015 0.012" "0.01 0.006" "0.008 0.006" "0.01 0.012" "0.008 0.012"]
|
||||
set chamf_equal_dist [list "0.01 " "0.008 " "0.01 " "0.015 " "0.01 " "0.008 " "0.01 " "0.008 "]
|
||||
if { [string compare $command chamf] == 0 } {
|
||||
puts "TODO OCC22909 All:chamfer is not done. compute of chamfer failed"
|
||||
if { [string compare $group equal_dist] != 0 } {
|
||||
puts "TODO OCC22909 All:chamfer is not done. compute of chamfer failed"
|
||||
}
|
||||
}
|
||||
|
25
tests/demo/draw/binpersist_1
Normal file
25
tests/demo/draw/binpersist_1
Normal file
@@ -0,0 +1,25 @@
|
||||
# test binsave and binrestore commands
|
||||
|
||||
pload TOPTEST
|
||||
|
||||
set file binpersist.bin
|
||||
|
||||
box b 10 20 30 100 200 300
|
||||
|
||||
if [regexp "Cannot write to the file $file" [binsave b $file]] {
|
||||
puts "Error: binsave"
|
||||
} elseif [regexp "Cannot read from the file $file" [binrestore $file bb]] {
|
||||
puts "Error: binrestore"
|
||||
} else {
|
||||
file delete $file
|
||||
if {[bounding b] != [bounding bb]} {
|
||||
puts "Error: restored shape has another bounding box"
|
||||
}
|
||||
checkshape bb
|
||||
checknbshapes bb -ref [nbshapes b]
|
||||
checkprops bb -l 4800
|
||||
checkprops bb -s 220000
|
||||
checkprops bb -v 6000000
|
||||
}
|
||||
|
||||
puts "TEST COMPLETED"
|
25
tests/demo/draw/binpersist_2
Normal file
25
tests/demo/draw/binpersist_2
Normal file
@@ -0,0 +1,25 @@
|
||||
# test binsave and binrestore commands
|
||||
|
||||
pload TOPTEST
|
||||
|
||||
set file binpersist.bin
|
||||
|
||||
restore [locate_data_file bug23849_segment_2.brep] b
|
||||
|
||||
if [regexp "Cannot write to the file $file" [binsave b $file]] {
|
||||
puts "Error: binsave"
|
||||
} elseif [regexp "Cannot read from the file $file" [binrestore $file bb]] {
|
||||
puts "Error: binrestore"
|
||||
} else {
|
||||
file delete $file
|
||||
if {[bounding b] != [bounding bb]} {
|
||||
puts "Error: restored shape has another bounding box"
|
||||
}
|
||||
checkshape bb
|
||||
checknbshapes bb -ref [nbshapes b]
|
||||
checkprops bb -l 7703.49
|
||||
checkprops bb -s 10678.2
|
||||
checkprops bb -v 67245
|
||||
}
|
||||
|
||||
puts "TEST COMPLETED"
|
26
tests/demo/draw/binpersist_3
Normal file
26
tests/demo/draw/binpersist_3
Normal file
@@ -0,0 +1,26 @@
|
||||
# test binsave and binrestore commands
|
||||
|
||||
pload TOPTEST
|
||||
|
||||
set file binpersist.bin
|
||||
|
||||
restore [locate_data_file OCC615.brep] b
|
||||
|
||||
if [regexp "Cannot write to the file $file" [binsave b $file]] {
|
||||
puts "Error: binsave"
|
||||
} elseif [regexp "Cannot read from the file $file" [binrestore $file bb]] {
|
||||
puts "Error: binrestore"
|
||||
} else {
|
||||
file delete $file
|
||||
if {[bounding b] != [bounding bb]} {
|
||||
puts "Error: restored shape has another bounding box"
|
||||
}
|
||||
checkshape bb
|
||||
checknbshapes bb -ref [nbshapes b]
|
||||
checkprops bb -l 5501.4
|
||||
checkprops bb -s 201237
|
||||
checkprops bb -v 4.68509e+006
|
||||
checktrinfo bb -ref [trinfo b]
|
||||
}
|
||||
|
||||
puts "TEST COMPLETED"
|
Reference in New Issue
Block a user