From: Andrea Mola Date: Mon, 10 Nov 2014 16:58:50 +0000 (+0100) Subject: added write support (with tests) for step files X-Git-Tag: v8.2.0-rc1~66^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84c5b1aec456f27793e26685de3aca6fa76bd696;p=dealii.git added write support (with tests) for step files --- diff --git a/doc/news/changes.h b/doc/news/changes.h index 9c43d0ff51..4ca91ec1cb 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -333,6 +333,13 @@ inconvenience this causes.

Specific improvements

    +
  1. New: Added support for STEP files in the OpenCASCADE + wrappers. STEP files can now be imported and exported respectively + with the read_STEP and write_STEP functions. +
    + (Andrea Mola, 2014/11/12) +
  2. +
  3. New: Timer now has get_lap_time() which returns the time lapsed between the last start()/stop() cycle.
    diff --git a/include/deal.II/opencascade/utilities.h b/include/deal.II/opencascade/utilities.h index dd204b4383..40228c69b0 100644 --- a/include/deal.II/opencascade/utilities.h +++ b/include/deal.II/opencascade/utilities.h @@ -112,7 +112,7 @@ namespace OpenCASCADE */ TopoDS_Shape read_IGES(const std::string &filename, const double scale_factor=1e-3); - + /** * Write the given topological shape into an IGES file. */ @@ -129,7 +129,13 @@ namespace OpenCASCADE */ TopoDS_Shape read_STEP(const std::string &filename, const double scale_factor=1e-3); - + + + /** + * Write the given topological shape into an STEP file. + */ + void write_STEP(const TopoDS_Shape &shape, + const std::string &filename); /** * This function returns the tolerance associated with the shape. diff --git a/source/opencascade/utilities.cc b/source/opencascade/utilities.cc index 0ecdf5966a..218342107e 100644 --- a/source/opencascade/utilities.cc +++ b/source/opencascade/utilities.cc @@ -220,7 +220,7 @@ namespace OpenCASCADE Standard_Boolean OK = ICW.Write (filename.c_str()); AssertThrow(OK, ExcMessage("Failed to write IGES file.")); } - + TopoDS_Shape read_STEP(const std::string &filename, const double scale_factor) { @@ -254,6 +254,22 @@ namespace OpenCASCADE return trans.Shape(); // this is the actual translation } + void write_STEP(const TopoDS_Shape &shape, + const std::string &filename) + { + + STEPControl_Controller::Init(); + STEPControl_Writer SCW; + IFSelect_ReturnStatus status; + status = SCW.Transfer(shape, STEPControl_AsIs); + AssertThrow(status = IFSelect_RetDone, ExcMessage("Failed to add shape to STEP controller.")); + + status = SCW.Write(filename.c_str()); + + AssertThrow(status = IFSelect_RetDone, ExcMessage("Failed to write translated shape to STEP file.")); + + + } double get_shape_tolerance(const TopoDS_Shape &shape) { diff --git a/tests/opencascade/iges_create.cc b/tests/opencascade/iges_create.cc index 59ccfa9959..182f737c45 100644 --- a/tests/opencascade/iges_create.cc +++ b/tests/opencascade/iges_create.cc @@ -24,7 +24,7 @@ using namespace OpenCASCADE; int main () { - // Create a bspline passign through the points + // Create a bspline passing through the points std::vector > pts; pts.push_back(Point<3>(0,0,0)); pts.push_back(Point<3>(0,1,0)); diff --git a/tests/opencascade/step_create.cc b/tests/opencascade/step_create.cc new file mode 100644 index 0000000000..1e83f504b5 --- /dev/null +++ b/tests/opencascade/step_create.cc @@ -0,0 +1,58 @@ +//----------------------------------------------------------- +// +// Copyright (C) 2014 by the deal.II authors +// +// This file is subject to LGPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//----------------------------------------------------------- + +// Create a bspline, and write it as an IGES file. + +#include "../tests.h" +#include +#include + +#include +#include +#include +#include + +using namespace OpenCASCADE; + +int main () +{ + // Create a bspline passing through the points + std::vector > pts; + pts.push_back(Point<3>(0,0,0)); + pts.push_back(Point<3>(0,1,0)); + pts.push_back(Point<3>(1,1,0)); + pts.push_back(Point<3>(1,0,0)); + + TopoDS_Edge edge = interpolation_curve(pts); + write_STEP(edge, "tmp.step"); + std::ifstream in("tmp.step"); + std::ofstream out("output"); + std::string line; + unsigned int counter = 0; + + while(std::getline(in,line)) + { + counter++; + if ( (counter == 4) || + (counter == 5) || + (counter == 6) || + (counter == 18) || + (counter == 19) ) + { + } + else + out << line << std::endl; + } + in.close(); + out.close(); + return 0; +} + diff --git a/tests/opencascade/step_create.output b/tests/opencascade/step_create.output new file mode 100644 index 0000000000..1c2964058e --- /dev/null +++ b/tests/opencascade/step_create.output @@ -0,0 +1,47 @@ +ISO-10303-21; +HEADER; +FILE_DESCRIPTION(('Open CASCADE Model'),'2;1'); +FILE_SCHEMA(('AUTOMOTIVE_DESIGN_CC2 { 1 2 10303 214 -1 1 5 4 }')); +ENDSEC; +DATA; +#1 = APPLICATION_PROTOCOL_DEFINITION('committee draft', + 'automotive_design',1997,#2); +#2 = APPLICATION_CONTEXT( + 'core data for automotive mechanical design processes'); +#3 = SHAPE_DEFINITION_REPRESENTATION(#4,#10); +#4 = PRODUCT_DEFINITION_SHAPE('','',#5); +#5 = PRODUCT_DEFINITION('design','',#6,#9); +#6 = PRODUCT_DEFINITION_FORMATION('','',#7); +#8 = MECHANICAL_CONTEXT('',#2,'mechanical'); +#9 = PRODUCT_DEFINITION_CONTEXT('part definition',#2,'design'); +#10 = GEOMETRICALLY_BOUNDED_WIREFRAME_SHAPE_REPRESENTATION('',(#11,#15), + #26); +#11 = AXIS2_PLACEMENT_3D('',#12,#13,#14); +#12 = CARTESIAN_POINT('',(0.,0.,0.)); +#13 = DIRECTION('',(0.,0.,1.)); +#14 = DIRECTION('',(1.,0.,-0.)); +#15 = GEOMETRIC_CURVE_SET('',(#16)); +#16 = TRIMMED_CURVE('',#17,(#24,PARAMETER_VALUE(0.)),(#25, + PARAMETER_VALUE(3.)),.T.,.PARAMETER.); +#17 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#18,#19,#20,#21,#22,#23), + .UNSPECIFIED.,.F.,.F.,(4,1,1,4),(0.,1.,2.,3.),.QUASI_UNIFORM_KNOTS.); +#18 = CARTESIAN_POINT('',(0.,0.,0.)); +#19 = CARTESIAN_POINT('',(-0.388888888889,0.5,0.)); +#20 = CARTESIAN_POINT('',(-0.166666666667,1.166666666667,0.)); +#21 = CARTESIAN_POINT('',(1.166666666667,1.166666666667,0.)); +#22 = CARTESIAN_POINT('',(1.388888888889,0.5,-0.)); +#23 = CARTESIAN_POINT('',(1.,0.,0.)); +#24 = CARTESIAN_POINT('',(0.,0.,0.)); +#25 = CARTESIAN_POINT('',(1.,0.,0.)); +#26 = ( GEOMETRIC_REPRESENTATION_CONTEXT(3) +GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#30)) GLOBAL_UNIT_ASSIGNED_CONTEXT( +(#27,#28,#29)) REPRESENTATION_CONTEXT('Context #1', + '3D Context with UNIT and UNCERTAINTY') ); +#27 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) ); +#28 = ( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) ); +#29 = ( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() ); +#30 = UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.E-07),#27, + 'distance_accuracy_value','confusion accuracy'); +#31 = PRODUCT_TYPE('part',$,(#7)); +ENDSEC; +END-ISO-10303-21; diff --git a/tests/opencascade/step_files/wigley.step b/tests/opencascade/step_files/wigley.step new file mode 100644 index 0000000000..c8a8d8cfb8 --- /dev/null +++ b/tests/opencascade/step_files/wigley.step @@ -0,0 +1,190 @@ +ISO-10303-21; +HEADER; +FILE_DESCRIPTION(('Open CASCADE Model'),'2;1'); +FILE_NAME('Open CASCADE Shape Model','2014-11-10T17:00:42',('Author'),( + 'Open CASCADE'),'Open CASCADE STEP processor 6.7','Open CASCADE 6.7' + ,'Unknown'); +FILE_SCHEMA(('AUTOMOTIVE_DESIGN_CC2 { 1 2 10303 214 -1 1 5 4 }')); +ENDSEC; +DATA; +#1 = APPLICATION_PROTOCOL_DEFINITION('committee draft', + 'automotive_design',1997,#2); +#2 = APPLICATION_CONTEXT( + 'core data for automotive mechanical design processes'); +#3 = SHAPE_DEFINITION_REPRESENTATION(#4,#10); +#4 = PRODUCT_DEFINITION_SHAPE('','',#5); +#5 = PRODUCT_DEFINITION('design','',#6,#9); +#6 = PRODUCT_DEFINITION_FORMATION('','',#7); +#7 = PRODUCT('Open CASCADE STEP translator 6.7 1', + 'Open CASCADE STEP translator 6.7 1','',(#8)); +#8 = MECHANICAL_CONTEXT('',#2,'mechanical'); +#9 = PRODUCT_DEFINITION_CONTEXT('part definition',#2,'design'); +#10 = MANIFOLD_SURFACE_SHAPE_REPRESENTATION('',(#11,#15),#147); +#11 = AXIS2_PLACEMENT_3D('',#12,#13,#14); +#12 = CARTESIAN_POINT('',(0.,0.,0.)); +#13 = DIRECTION('',(0.,0.,1.)); +#14 = DIRECTION('',(1.,0.,-0.)); +#15 = SHELL_BASED_SURFACE_MODEL('',(#16)); +#16 = OPEN_SHELL('',(#17)); +#17 = ADVANCED_FACE('',(#18),#40,.T.); +#18 = FACE_BOUND('',#19,.T.); +#19 = EDGE_LOOP('',(#20,#91,#108,#132)); +#20 = ORIENTED_EDGE('',*,*,#21,.F.); +#21 = EDGE_CURVE('',#22,#24,#26,.T.); +#22 = VERTEX_POINT('',#23); +#23 = CARTESIAN_POINT('',(-1.25,0.,0.15625)); +#24 = VERTEX_POINT('',#25); +#25 = CARTESIAN_POINT('',(-1.25,6.938893904E-18,-0.15625)); +#26 = SURFACE_CURVE('',#27,(#39),.PCURVE_S1.); +#27 = B_SPLINE_CURVE_WITH_KNOTS('',4,(#28,#29,#30,#31,#32,#33,#34,#35, + #36,#37,#38),.UNSPECIFIED.,.F.,.F.,(5,3,3,5),(0.,0.434398431, + 0.67839972,1.),.UNSPECIFIED.); +#28 = CARTESIAN_POINT('',(-1.25,0.,0.15625)); +#29 = CARTESIAN_POINT('',(-1.25,0.,0.1171875)); +#30 = CARTESIAN_POINT('',(-1.25,0.,7.8125E-02)); +#31 = CARTESIAN_POINT('',(-1.25,0.,3.90625E-02)); +#32 = CARTESIAN_POINT('',(-1.25,0.,-2.194137841E-02)); +#33 = CARTESIAN_POINT('',(-1.25,0.,-4.186850308E-02)); +#34 = CARTESIAN_POINT('',(-1.25,0.,-6.051483061E-02)); +#35 = CARTESIAN_POINT('',(-1.25,0.,-0.101335678)); +#36 = CARTESIAN_POINT('',(-1.25,0.,-0.121016618)); +#37 = CARTESIAN_POINT('',(-1.25,0.,-0.139275692)); +#38 = CARTESIAN_POINT('',(-1.25,0.,-0.15625)); +#39 = PCURVE('',#40,#85); +#40 = B_SPLINE_SURFACE_WITH_KNOTS('',3,4,( + (#41,#42,#43,#44,#45,#46,#47,#48,#49,#50,#51) + ,(#52,#53,#54,#55,#56,#57,#58,#59,#60,#61,#62) + ,(#63,#64,#65,#66,#67,#68,#69,#70,#71,#72,#73) + ,(#74,#75,#76,#77,#78,#79,#80,#81,#82,#83,#84 + )),.UNSPECIFIED.,.F.,.F.,.F.,(4,4),(5,3,3,5),(0.,1.),(0.,0.434398431, + 0.67839972,1.),.UNSPECIFIED.); +#41 = CARTESIAN_POINT('',(-1.25,0.,0.15625)); +#42 = CARTESIAN_POINT('',(-1.25,0.,0.1171875)); +#43 = CARTESIAN_POINT('',(-1.25,0.,7.8125E-02)); +#44 = CARTESIAN_POINT('',(-1.25,0.,3.90625E-02)); +#45 = CARTESIAN_POINT('',(-1.25,0.,-2.194137841E-02)); +#46 = CARTESIAN_POINT('',(-1.25,0.,-4.186850308E-02)); +#47 = CARTESIAN_POINT('',(-1.25,0.,-6.051483061E-02)); +#48 = CARTESIAN_POINT('',(-1.25,0.,-0.101335678)); +#49 = CARTESIAN_POINT('',(-1.25,0.,-0.121016618)); +#50 = CARTESIAN_POINT('',(-1.25,0.,-0.139275692)); +#51 = CARTESIAN_POINT('',(-1.25,0.,-0.15625)); +#52 = CARTESIAN_POINT('',(-0.427535926,0.166356581,0.15625)); +#53 = CARTESIAN_POINT('',(-0.427535926,0.166356581,0.1171875)); +#54 = CARTESIAN_POINT('',(-0.427535926,0.166356581,7.8125E-02)); +#55 = CARTESIAN_POINT('',(-0.427535926,0.166356581,3.90625E-02)); +#56 = CARTESIAN_POINT('',(-0.427537148,0.166340839,-2.194137841E-02)); +#57 = CARTESIAN_POINT('',(-0.426411306,0.157707663,-4.186850308E-02)); +#58 = CARTESIAN_POINT('',(-0.424671145,0.14360916,-6.051483061E-02)); +#59 = CARTESIAN_POINT('',(-0.420417595,0.100130616,-0.101335678)); +#60 = CARTESIAN_POINT('',(-0.418058171,6.969502649E-02,-0.121016618)); +#61 = CARTESIAN_POINT('',(-0.416669646,3.62728606E-02,-0.139275692)); +#62 = CARTESIAN_POINT('',(-0.416666667,0.,-0.15625)); +#63 = CARTESIAN_POINT('',(0.427535926,0.166356581,0.15625)); +#64 = CARTESIAN_POINT('',(0.427535926,0.166356581,0.1171875)); +#65 = CARTESIAN_POINT('',(0.427535926,0.166356581,7.8125E-02)); +#66 = CARTESIAN_POINT('',(0.427535926,0.166356581,3.90625E-02)); +#67 = CARTESIAN_POINT('',(0.427537148,0.166340839,-2.194137841E-02)); +#68 = CARTESIAN_POINT('',(0.426411306,0.157707663,-4.186850308E-02)); +#69 = CARTESIAN_POINT('',(0.424671145,0.14360916,-6.051483061E-02)); +#70 = CARTESIAN_POINT('',(0.420417595,0.100130616,-0.101335678)); +#71 = CARTESIAN_POINT('',(0.418058171,6.969502649E-02,-0.121016618)); +#72 = CARTESIAN_POINT('',(0.416669646,3.62728606E-02,-0.139275692)); +#73 = CARTESIAN_POINT('',(0.416666667,0.,-0.15625)); +#74 = CARTESIAN_POINT('',(1.25,-3.885780586E-16,0.15625)); +#75 = CARTESIAN_POINT('',(1.25,-3.885780586E-16,0.1171875)); +#76 = CARTESIAN_POINT('',(1.25,-3.885780586E-16,7.8125E-02)); +#77 = CARTESIAN_POINT('',(1.25,-3.885780586E-16,3.90625E-02)); +#78 = CARTESIAN_POINT('',(1.25,-3.885524483E-16,-2.194137841E-02)); +#79 = CARTESIAN_POINT('',(1.25,-3.683109958E-16,-4.186850308E-02)); +#80 = CARTESIAN_POINT('',(1.25,-3.352606389E-16,-6.051483061E-02)); +#81 = CARTESIAN_POINT('',(1.25,-2.335884101E-16,-0.101335678)); +#82 = CARTESIAN_POINT('',(1.25,-1.624730779E-16,-0.121016618)); +#83 = CARTESIAN_POINT('',(1.25,-8.457292169E-17,-0.139275692)); +#84 = CARTESIAN_POINT('',(1.25,0.,-0.15625)); +#85 = DEFINITIONAL_REPRESENTATION('',(#86),#90); +#86 = LINE('',#87,#88); +#87 = CARTESIAN_POINT('',(0.,0.)); +#88 = VECTOR('',#89,1.); +#89 = DIRECTION('',(-0.,1.)); +#90 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#91 = ORIENTED_EDGE('',*,*,#92,.T.); +#92 = EDGE_CURVE('',#22,#93,#95,.T.); +#93 = VERTEX_POINT('',#94); +#94 = CARTESIAN_POINT('',(1.25,-3.885780586E-16,0.15625)); +#95 = SURFACE_CURVE('',#96,(#101),.PCURVE_S1.); +#96 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#97,#98,#99,#100),.UNSPECIFIED., + .F.,.F.,(4,4),(0.,1.),.PIECEWISE_BEZIER_KNOTS.); +#97 = CARTESIAN_POINT('',(-1.25,0.,0.15625)); +#98 = CARTESIAN_POINT('',(-0.427535926,0.166356581,0.15625)); +#99 = CARTESIAN_POINT('',(0.427535926,0.166356581,0.15625)); +#100 = CARTESIAN_POINT('',(1.25,-3.885780586E-16,0.15625)); +#101 = PCURVE('',#40,#102); +#102 = DEFINITIONAL_REPRESENTATION('',(#103),#107); +#103 = LINE('',#104,#105); +#104 = CARTESIAN_POINT('',(0.,0.)); +#105 = VECTOR('',#106,1.); +#106 = DIRECTION('',(1.,0.)); +#107 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#108 = ORIENTED_EDGE('',*,*,#109,.T.); +#109 = EDGE_CURVE('',#93,#110,#112,.T.); +#110 = VERTEX_POINT('',#111); +#111 = CARTESIAN_POINT('',(1.25,6.938893904E-18,-0.15625)); +#112 = SURFACE_CURVE('',#113,(#125),.PCURVE_S1.); +#113 = B_SPLINE_CURVE_WITH_KNOTS('',4,(#114,#115,#116,#117,#118,#119, + #120,#121,#122,#123,#124),.UNSPECIFIED.,.F.,.F.,(5,3,3,5),(0., + 0.434398431,0.67839972,1.),.UNSPECIFIED.); +#114 = CARTESIAN_POINT('',(1.25,-3.885780586E-16,0.15625)); +#115 = CARTESIAN_POINT('',(1.25,-3.885780586E-16,0.1171875)); +#116 = CARTESIAN_POINT('',(1.25,-3.885780586E-16,7.8125E-02)); +#117 = CARTESIAN_POINT('',(1.25,-3.885780586E-16,3.90625E-02)); +#118 = CARTESIAN_POINT('',(1.25,-3.885524483E-16,-2.194137841E-02)); +#119 = CARTESIAN_POINT('',(1.25,-3.683109958E-16,-4.186850308E-02)); +#120 = CARTESIAN_POINT('',(1.25,-3.352606389E-16,-6.051483061E-02)); +#121 = CARTESIAN_POINT('',(1.25,-2.335884101E-16,-0.101335678)); +#122 = CARTESIAN_POINT('',(1.25,-1.624730779E-16,-0.121016618)); +#123 = CARTESIAN_POINT('',(1.25,-8.457292169E-17,-0.139275692)); +#124 = CARTESIAN_POINT('',(1.25,0.,-0.15625)); +#125 = PCURVE('',#40,#126); +#126 = DEFINITIONAL_REPRESENTATION('',(#127),#131); +#127 = LINE('',#128,#129); +#128 = CARTESIAN_POINT('',(1.,0.)); +#129 = VECTOR('',#130,1.); +#130 = DIRECTION('',(0.,1.)); +#131 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#132 = ORIENTED_EDGE('',*,*,#133,.F.); +#133 = EDGE_CURVE('',#24,#110,#134,.T.); +#134 = SURFACE_CURVE('',#135,(#140),.PCURVE_S1.); +#135 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#136,#137,#138,#139), + .UNSPECIFIED.,.F.,.F.,(4,4),(0.,1.),.PIECEWISE_BEZIER_KNOTS.); +#136 = CARTESIAN_POINT('',(-1.25,0.,-0.15625)); +#137 = CARTESIAN_POINT('',(-0.416666667,0.,-0.15625)); +#138 = CARTESIAN_POINT('',(0.416666667,0.,-0.15625)); +#139 = CARTESIAN_POINT('',(1.25,0.,-0.15625)); +#140 = PCURVE('',#40,#141); +#141 = DEFINITIONAL_REPRESENTATION('',(#142),#146); +#142 = LINE('',#143,#144); +#143 = CARTESIAN_POINT('',(0.,1.)); +#144 = VECTOR('',#145,1.); +#145 = DIRECTION('',(1.,-0.)); +#146 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#147 = ( GEOMETRIC_REPRESENTATION_CONTEXT(3) +GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#151)) GLOBAL_UNIT_ASSIGNED_CONTEXT +((#148,#149,#150)) REPRESENTATION_CONTEXT('Context #1', + '3D Context with UNIT and UNCERTAINTY') ); +#148 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT($,.METRE.) ); +#149 = ( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) ); +#150 = ( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() ); +#151 = UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.E-07),#148, + 'distance_accuracy_value','confusion accuracy'); +#152 = PRODUCT_TYPE('part',$,(#7)); +ENDSEC; +END-ISO-10303-21; diff --git a/tests/opencascade/step_write.cc b/tests/opencascade/step_write.cc new file mode 100644 index 0000000000..3b1abaf2d8 --- /dev/null +++ b/tests/opencascade/step_write.cc @@ -0,0 +1,53 @@ +//----------------------------------------------------------- +// +// Copyright (C) 2014 by the deal.II authors +// +// This file is subject to LGPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//----------------------------------------------------------- + +// Read a file in iges format, and write it out again in the same +// format. + +#include "../tests.h" +#include +#include + +#include +#include +#include +#include + +using namespace OpenCASCADE; + +int main () +{ + TopoDS_Shape sh = read_STEP(SOURCE_DIR "/step_files/wigley.step"); + write_STEP(sh, "tmp.step"); + std::ifstream in("tmp.step"); + std::ofstream out("output"); + std::string line; + unsigned int counter = 0; + + while(std::getline(in,line)) + { + counter++; + if ( (counter == 4) || + (counter == 5) || + (counter == 6) || + (counter == 18) || + (counter == 19) ) + { + } + else + out << line << std::endl; + } + + + in.close(); + out.close(); + return 0; +} diff --git a/tests/opencascade/step_write.output b/tests/opencascade/step_write.output new file mode 100644 index 0000000000..4139e07184 --- /dev/null +++ b/tests/opencascade/step_write.output @@ -0,0 +1,197 @@ +ISO-10303-21; +HEADER; +FILE_DESCRIPTION(('Open CASCADE Model'),'2;1'); +FILE_SCHEMA(('AUTOMOTIVE_DESIGN_CC2 { 1 2 10303 214 -1 1 5 4 }')); +ENDSEC; +DATA; +#1 = APPLICATION_PROTOCOL_DEFINITION('committee draft', + 'automotive_design',1997,#2); +#2 = APPLICATION_CONTEXT( + 'core data for automotive mechanical design processes'); +#3 = SHAPE_DEFINITION_REPRESENTATION(#4,#10); +#4 = PRODUCT_DEFINITION_SHAPE('','',#5); +#5 = PRODUCT_DEFINITION('design','',#6,#9); +#6 = PRODUCT_DEFINITION_FORMATION('','',#7); +#8 = MECHANICAL_CONTEXT('',#2,'mechanical'); +#9 = PRODUCT_DEFINITION_CONTEXT('part definition',#2,'design'); +#10 = MANIFOLD_SURFACE_SHAPE_REPRESENTATION('',(#11,#15),#143); +#11 = AXIS2_PLACEMENT_3D('',#12,#13,#14); +#12 = CARTESIAN_POINT('',(0.,0.,0.)); +#13 = DIRECTION('',(0.,0.,1.)); +#14 = DIRECTION('',(1.,0.,-0.)); +#15 = SHELL_BASED_SURFACE_MODEL('',(#16)); +#16 = OPEN_SHELL('',(#17)); +#17 = ADVANCED_FACE('',(#18),#40,.T.); +#18 = FACE_BOUND('',#19,.T.); +#19 = EDGE_LOOP('',(#20,#90,#106,#129)); +#20 = ORIENTED_EDGE('',*,*,#21,.F.); +#21 = EDGE_CURVE('',#22,#24,#26,.T.); +#22 = VERTEX_POINT('',#23); +#23 = CARTESIAN_POINT('',(-1.25E-03,0.,1.5625E-04)); +#24 = VERTEX_POINT('',#25); +#25 = CARTESIAN_POINT('',(-1.25E-03,6.938893904E-21,-1.5625E-04)); +#26 = SURFACE_CURVE('',#27,(#39),.PCURVE_S1.); +#27 = B_SPLINE_CURVE_WITH_KNOTS('',4,(#28,#29,#30,#31,#32,#33,#34,#35, + #36,#37,#38),.UNSPECIFIED.,.F.,.F.,(5,3,3,5),(0.,0.434398431, + 0.67839972,1.),.UNSPECIFIED.); +#28 = CARTESIAN_POINT('',(-1.25E-03,0.,1.5625E-04)); +#29 = CARTESIAN_POINT('',(-1.25E-03,0.,1.171875E-04)); +#30 = CARTESIAN_POINT('',(-1.25E-03,0.,7.8125E-05)); +#31 = CARTESIAN_POINT('',(-1.25E-03,0.,3.90625E-05)); +#32 = CARTESIAN_POINT('',(-1.25E-03,0.,-2.194137841E-05)); +#33 = CARTESIAN_POINT('',(-1.25E-03,0.,-4.186850308E-05)); +#34 = CARTESIAN_POINT('',(-1.25E-03,0.,-6.051483061E-05)); +#35 = CARTESIAN_POINT('',(-1.25E-03,0.,-1.01335678E-04)); +#36 = CARTESIAN_POINT('',(-1.25E-03,0.,-1.21016618E-04)); +#37 = CARTESIAN_POINT('',(-1.25E-03,0.,-1.39275692E-04)); +#38 = CARTESIAN_POINT('',(-1.25E-03,0.,-1.5625E-04)); +#39 = PCURVE('',#40,#85); +#40 = B_SPLINE_SURFACE_WITH_KNOTS('',3,4,( + (#41,#42,#43,#44,#45,#46,#47,#48,#49,#50,#51) + ,(#52,#53,#54,#55,#56,#57,#58,#59,#60,#61,#62) + ,(#63,#64,#65,#66,#67,#68,#69,#70,#71,#72,#73) + ,(#74,#75,#76,#77,#78,#79,#80,#81,#82,#83,#84 + )),.UNSPECIFIED.,.F.,.F.,.F.,(4,4),(5,3,3,5),(0.,1.),(0.,0.434398431, + 0.67839972,1.),.UNSPECIFIED.); +#41 = CARTESIAN_POINT('',(-1.25E-03,0.,1.5625E-04)); +#42 = CARTESIAN_POINT('',(-1.25E-03,0.,1.171875E-04)); +#43 = CARTESIAN_POINT('',(-1.25E-03,0.,7.8125E-05)); +#44 = CARTESIAN_POINT('',(-1.25E-03,0.,3.90625E-05)); +#45 = CARTESIAN_POINT('',(-1.25E-03,0.,-2.194137841E-05)); +#46 = CARTESIAN_POINT('',(-1.25E-03,0.,-4.186850308E-05)); +#47 = CARTESIAN_POINT('',(-1.25E-03,0.,-6.051483061E-05)); +#48 = CARTESIAN_POINT('',(-1.25E-03,0.,-1.01335678E-04)); +#49 = CARTESIAN_POINT('',(-1.25E-03,0.,-1.21016618E-04)); +#50 = CARTESIAN_POINT('',(-1.25E-03,0.,-1.39275692E-04)); +#51 = CARTESIAN_POINT('',(-1.25E-03,0.,-1.5625E-04)); +#52 = CARTESIAN_POINT('',(-4.27535926E-04,1.66356581E-04,1.5625E-04)); +#53 = CARTESIAN_POINT('',(-4.27535926E-04,1.66356581E-04,1.171875E-04)); +#54 = CARTESIAN_POINT('',(-4.27535926E-04,1.66356581E-04,7.8125E-05)); +#55 = CARTESIAN_POINT('',(-4.27535926E-04,1.66356581E-04,3.90625E-05)); +#56 = CARTESIAN_POINT('',(-4.27537148E-04,1.66340839E-04, + -2.194137841E-05)); +#57 = CARTESIAN_POINT('',(-4.26411306E-04,1.57707663E-04, + -4.186850308E-05)); +#58 = CARTESIAN_POINT('',(-4.24671145E-04,1.4360916E-04,-6.051483061E-05 + )); +#59 = CARTESIAN_POINT('',(-4.20417595E-04,1.00130616E-04,-1.01335678E-04 + )); +#60 = CARTESIAN_POINT('',(-4.18058171E-04,6.969502649E-05, + -1.21016618E-04)); +#61 = CARTESIAN_POINT('',(-4.16669646E-04,3.62728606E-05,-1.39275692E-04 + )); +#62 = CARTESIAN_POINT('',(-4.16666667E-04,0.,-1.5625E-04)); +#63 = CARTESIAN_POINT('',(4.27535926E-04,1.66356581E-04,1.5625E-04)); +#64 = CARTESIAN_POINT('',(4.27535926E-04,1.66356581E-04,1.171875E-04)); +#65 = CARTESIAN_POINT('',(4.27535926E-04,1.66356581E-04,7.8125E-05)); +#66 = CARTESIAN_POINT('',(4.27535926E-04,1.66356581E-04,3.90625E-05)); +#67 = CARTESIAN_POINT('',(4.27537148E-04,1.66340839E-04,-2.194137841E-05 + )); +#68 = CARTESIAN_POINT('',(4.26411306E-04,1.57707663E-04,-4.186850308E-05 + )); +#69 = CARTESIAN_POINT('',(4.24671145E-04,1.4360916E-04,-6.051483061E-05) + ); +#70 = CARTESIAN_POINT('',(4.20417595E-04,1.00130616E-04,-1.01335678E-04) + ); +#71 = CARTESIAN_POINT('',(4.18058171E-04,6.969502649E-05,-1.21016618E-04 + )); +#72 = CARTESIAN_POINT('',(4.16669646E-04,3.62728606E-05,-1.39275692E-04) + ); +#73 = CARTESIAN_POINT('',(4.16666667E-04,0.,-1.5625E-04)); +#74 = CARTESIAN_POINT('',(1.25E-03,-3.885780586E-19,1.5625E-04)); +#75 = CARTESIAN_POINT('',(1.25E-03,-3.885780586E-19,1.171875E-04)); +#76 = CARTESIAN_POINT('',(1.25E-03,-3.885780586E-19,7.8125E-05)); +#77 = CARTESIAN_POINT('',(1.25E-03,-3.885780586E-19,3.90625E-05)); +#78 = CARTESIAN_POINT('',(1.25E-03,-3.885524483E-19,-2.194137841E-05)); +#79 = CARTESIAN_POINT('',(1.25E-03,-3.683109958E-19,-4.186850308E-05)); +#80 = CARTESIAN_POINT('',(1.25E-03,-3.352606389E-19,-6.051483061E-05)); +#81 = CARTESIAN_POINT('',(1.25E-03,-2.335884101E-19,-1.01335678E-04)); +#82 = CARTESIAN_POINT('',(1.25E-03,-1.624730779E-19,-1.21016618E-04)); +#83 = CARTESIAN_POINT('',(1.25E-03,-8.457292169E-20,-1.39275692E-04)); +#84 = CARTESIAN_POINT('',(1.25E-03,0.,-1.5625E-04)); +#85 = DEFINITIONAL_REPRESENTATION('',(#86),#89); +#86 = B_SPLINE_CURVE_WITH_KNOTS('',1,(#87,#88),.UNSPECIFIED.,.F.,.F.,(2, + 2),(0.,1.),.PIECEWISE_BEZIER_KNOTS.); +#87 = CARTESIAN_POINT('',(0.,0.)); +#88 = CARTESIAN_POINT('',(0.,1.)); +#89 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#90 = ORIENTED_EDGE('',*,*,#91,.T.); +#91 = EDGE_CURVE('',#22,#92,#94,.T.); +#92 = VERTEX_POINT('',#93); +#93 = CARTESIAN_POINT('',(1.25E-03,-3.885780586E-19,1.5625E-04)); +#94 = SURFACE_CURVE('',#95,(#100),.PCURVE_S1.); +#95 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#96,#97,#98,#99),.UNSPECIFIED.,.F. + ,.F.,(4,4),(0.,1.),.PIECEWISE_BEZIER_KNOTS.); +#96 = CARTESIAN_POINT('',(-1.25E-03,0.,1.5625E-04)); +#97 = CARTESIAN_POINT('',(-4.27535926E-04,1.66356581E-04,1.5625E-04)); +#98 = CARTESIAN_POINT('',(4.27535926E-04,1.66356581E-04,1.5625E-04)); +#99 = CARTESIAN_POINT('',(1.25E-03,-3.885780586E-19,1.5625E-04)); +#100 = PCURVE('',#40,#101); +#101 = DEFINITIONAL_REPRESENTATION('',(#102),#105); +#102 = B_SPLINE_CURVE_WITH_KNOTS('',1,(#103,#104),.UNSPECIFIED.,.F.,.F., + (2,2),(0.,1.),.PIECEWISE_BEZIER_KNOTS.); +#103 = CARTESIAN_POINT('',(0.,0.)); +#104 = CARTESIAN_POINT('',(1.,0.)); +#105 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#106 = ORIENTED_EDGE('',*,*,#107,.T.); +#107 = EDGE_CURVE('',#92,#108,#110,.T.); +#108 = VERTEX_POINT('',#109); +#109 = CARTESIAN_POINT('',(1.25E-03,6.938893904E-21,-1.5625E-04)); +#110 = SURFACE_CURVE('',#111,(#123),.PCURVE_S1.); +#111 = B_SPLINE_CURVE_WITH_KNOTS('',4,(#112,#113,#114,#115,#116,#117, + #118,#119,#120,#121,#122),.UNSPECIFIED.,.F.,.F.,(5,3,3,5),(0., + 0.434398431,0.67839972,1.),.UNSPECIFIED.); +#112 = CARTESIAN_POINT('',(1.25E-03,-3.885780586E-19,1.5625E-04)); +#113 = CARTESIAN_POINT('',(1.25E-03,-3.885780586E-19,1.171875E-04)); +#114 = CARTESIAN_POINT('',(1.25E-03,-3.885780586E-19,7.8125E-05)); +#115 = CARTESIAN_POINT('',(1.25E-03,-3.885780586E-19,3.90625E-05)); +#116 = CARTESIAN_POINT('',(1.25E-03,-3.885524483E-19,-2.194137841E-05)); +#117 = CARTESIAN_POINT('',(1.25E-03,-3.683109958E-19,-4.186850308E-05)); +#118 = CARTESIAN_POINT('',(1.25E-03,-3.352606389E-19,-6.051483061E-05)); +#119 = CARTESIAN_POINT('',(1.25E-03,-2.335884101E-19,-1.01335678E-04)); +#120 = CARTESIAN_POINT('',(1.25E-03,-1.624730779E-19,-1.21016618E-04)); +#121 = CARTESIAN_POINT('',(1.25E-03,-8.457292169E-20,-1.39275692E-04)); +#122 = CARTESIAN_POINT('',(1.25E-03,0.,-1.5625E-04)); +#123 = PCURVE('',#40,#124); +#124 = DEFINITIONAL_REPRESENTATION('',(#125),#128); +#125 = B_SPLINE_CURVE_WITH_KNOTS('',1,(#126,#127),.UNSPECIFIED.,.F.,.F., + (2,2),(0.,1.),.PIECEWISE_BEZIER_KNOTS.); +#126 = CARTESIAN_POINT('',(1.,0.)); +#127 = CARTESIAN_POINT('',(1.,1.)); +#128 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#129 = ORIENTED_EDGE('',*,*,#130,.F.); +#130 = EDGE_CURVE('',#24,#108,#131,.T.); +#131 = SURFACE_CURVE('',#132,(#137),.PCURVE_S1.); +#132 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#133,#134,#135,#136), + .UNSPECIFIED.,.F.,.F.,(4,4),(0.,1.),.PIECEWISE_BEZIER_KNOTS.); +#133 = CARTESIAN_POINT('',(-1.25E-03,0.,-1.5625E-04)); +#134 = CARTESIAN_POINT('',(-4.16666667E-04,0.,-1.5625E-04)); +#135 = CARTESIAN_POINT('',(4.16666667E-04,0.,-1.5625E-04)); +#136 = CARTESIAN_POINT('',(1.25E-03,0.,-1.5625E-04)); +#137 = PCURVE('',#40,#138); +#138 = DEFINITIONAL_REPRESENTATION('',(#139),#142); +#139 = B_SPLINE_CURVE_WITH_KNOTS('',1,(#140,#141),.UNSPECIFIED.,.F.,.F., + (2,2),(0.,1.),.PIECEWISE_BEZIER_KNOTS.); +#140 = CARTESIAN_POINT('',(0.,1.)); +#141 = CARTESIAN_POINT('',(1.,1.)); +#142 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) +PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' + ) ); +#143 = ( GEOMETRIC_REPRESENTATION_CONTEXT(3) +GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#147)) GLOBAL_UNIT_ASSIGNED_CONTEXT +((#144,#145,#146)) REPRESENTATION_CONTEXT('Context #1', + '3D Context with UNIT and UNCERTAINTY') ); +#144 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) ); +#145 = ( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) ); +#146 = ( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() ); +#147 = UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.E-07),#144, + 'distance_accuracy_value','confusion accuracy'); +#148 = PRODUCT_TYPE('part',$,(#7)); +ENDSEC; +END-ISO-10303-21;