]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added write_IGES routine.
authorLuca Heltai <luca.heltai@sissa.it>
Tue, 12 Aug 2014 16:07:50 +0000 (18:07 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Fri, 31 Oct 2014 10:06:33 +0000 (11:06 +0100)
Fixed typo in compilation, and header files.

Added iges_write test.

Fixed iges write.

Added iges_create test.

include/deal.II/grid/occ_utilities.h
source/grid/occ_utilities.cc
tests/opencascade/iges_create.cc [new file with mode: 0644]
tests/opencascade/iges_create.output [new file with mode: 0644]
tests/opencascade/iges_files/line.iges [new file with mode: 0644]
tests/opencascade/iges_files/line_02.iges [new file with mode: 0644]
tests/opencascade/iges_write.cc [new file with mode: 0644]
tests/opencascade/iges_write.output [new file with mode: 0644]

index d483b58e11bdec13a5688428fe79de6b8c0d31f0..074ca7ea1670afbf0f68c454db2966bf51307209 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <string>
 #include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
 #include <IFSelect_ReturnStatus.hxx>
 #include <Geom_Plane.hxx>
 #include <Geom_Curve.hxx>
@@ -109,6 +110,14 @@ 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.
+   */
+  void write_IGES(const TopoDS_Shape &shape, 
+                 const std::string &filename);
+                 
+  
+
   /**
    * Perform the intersection of the given topological shape with the
    * plane $c_x x + c_y y + c_z z +c = 0$. The returned topological
index 1bf4571e1b567a5fffb8e80aaca028c7e89387db..84db8fbf3b5fc9896835deadbd8b686a6d954d66 100644 (file)
@@ -9,10 +9,10 @@
 #include <iostream>
 #include <set>
 
-#include <IGESControl_Reader.hxx>
 #include <IGESControl_Controller.hxx>
+#include <IGESControl_Reader.hxx>
+#include <IGESControl_Writer.hxx>
 
-// #include <IGESControl_Writer.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
 // #include <TopoDS_Shell.hxx>
@@ -160,6 +160,18 @@ namespace OpenCASCADE
     return trans.Shape();   // this is the actual translation
   }
   
+  void write_IGES(const TopoDS_Shape &shape, 
+                 const std::string &filename) {
+    
+    IGESControl_Controller::Init();
+    IGESControl_Writer ICW ("MM", 0);
+    Standard_Boolean ok = ICW.AddShape (shape);
+    Assert(ok, ExcMessage("Failed to add shape to IGES controller."));
+    ICW.ComputeModel();
+    Standard_Boolean OK = ICW.Write (filename.c_str());
+    Assert(OK, ExcMessage("Failed to write IGES file."));
+  }
+  
 
    TopoDS_Shape intersect_plane(const TopoDS_Shape &in_shape,
                                const double c_x,
diff --git a/tests/opencascade/iges_create.cc b/tests/opencascade/iges_create.cc
new file mode 100644 (file)
index 0000000..c8cb5bf
--- /dev/null
@@ -0,0 +1,47 @@
+
+//----------------------------  iges_read.cc  ---------------------------
+//    $Id: testsuite.html 13373 2006-07-13 13:12:08Z kanschat $
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005 by the deal.II authors 
+//
+//    This file is subject to QPL 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.
+//
+//----------------------------  iges_read.cc  ---------------------------
+
+
+// Read goteborg.iges and dump its topological structure to the logfile.
+
+#include "../tests.h"
+#include <fstream>
+#include <base/logstream.h>
+
+#include <deal.II/grid/occ_utilities.h>
+#include <TopTools.hxx>
+#include <TopoDS_Shape.hxx>
+#include <Standard_Stream.hxx>
+
+using namespace OpenCASCADE;
+
+int main () 
+{
+  // std::ofstream logfile("output");
+  // deallog.attach(logfile);
+  // deallog.depth_console(0);
+  
+  // Create a bspline passign through the points
+  std::vector<Point<3> > 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_IGES(edge, "output");
+
+  return 0;
+}
+                  
diff --git a/tests/opencascade/iges_create.output b/tests/opencascade/iges_create.output
new file mode 100644 (file)
index 0000000..f803644
--- /dev/null
@@ -0,0 +1,12 @@
+                                                                        S0000001
+,,31HOpen CASCADE IGES processor 6.7,13HFilename.iges,                  G0000001
+16HOpen CASCADE 6.7,31HOpen CASCADE IGES processor 6.7,32,308,15,308,15,G0000002
+,1.,2,2HMM,1,0.01,15H20140813.171933,1E-07,1.309333,6Hheltai,,11,0,     G0000003
+15H20140813.171933,;                                                    G0000004
+     126       1       0       0       0       0       0       000000000D0000001
+     126       0       0       4       0                               0D0000002
+126,5,3,1,0,1,0,0.,0.,0.,0.,1.,2.,3.,3.,3.,3.,1.,1.,1.,1.,1.,1., 0000001P0000001
+0.,0.,0.,-0.388888889,0.5,0.,-0.166666667,1.166666667,0.,        0000001P0000002
+1.166666667,1.166666667,0.,1.388888889,0.5,-0.,1.,0.,0.,0.,3.,   0000001P0000003
+-0.,-0.,1.;                                                      0000001P0000004
+S      1G      4D      2P      4                                        T0000001
diff --git a/tests/opencascade/iges_files/line.iges b/tests/opencascade/iges_files/line.iges
new file mode 100644 (file)
index 0000000..974bdad
--- /dev/null
@@ -0,0 +1,13 @@
+                                                                        S0000001
+,,31HOpen CASCADE IGES processor 6.7,13HFilename.iges,                  G0000001
+16HOpen CASCADE 6.7,31HOpen CASCADE IGES processor 6.7,32,308,15,308,15,G0000002
+,1.,1,4HINCH,1,0.000394,15H20140813.165018,3.93701E-09,0.049451,        G0000003
+6Hheltai,,11,0,15H20140813.165018,;                                     G0000004
+     126       1       0       0       0       0       0       000000000D0000001
+     126       0       0       5       0                               0D0000002
+126,5,3,1,0,1,0,0.,0.,0.,0.,1.,2.,3.,3.,3.,3.,1.,1.,1.,1.,1.,1., 0000001P0000001
+0.,0.,0.,-1.531058618E-02,1.968503937E-02,0.,-6.56167979E-03,    0000001P0000002
+4.593175853E-02,0.,4.593175853E-02,4.593175853E-02,0.,           0000001P0000003
+5.468066492E-02,1.968503937E-02,0.,3.937007874E-02,0.,0.,0.,3.,  0000001P0000004
+-0.,-0.,1.;                                                      0000001P0000005
+S      1G      4D      2P      5                                        T0000001
diff --git a/tests/opencascade/iges_files/line_02.iges b/tests/opencascade/iges_files/line_02.iges
new file mode 100644 (file)
index 0000000..f803644
--- /dev/null
@@ -0,0 +1,12 @@
+                                                                        S0000001
+,,31HOpen CASCADE IGES processor 6.7,13HFilename.iges,                  G0000001
+16HOpen CASCADE 6.7,31HOpen CASCADE IGES processor 6.7,32,308,15,308,15,G0000002
+,1.,2,2HMM,1,0.01,15H20140813.171933,1E-07,1.309333,6Hheltai,,11,0,     G0000003
+15H20140813.171933,;                                                    G0000004
+     126       1       0       0       0       0       0       000000000D0000001
+     126       0       0       4       0                               0D0000002
+126,5,3,1,0,1,0,0.,0.,0.,0.,1.,2.,3.,3.,3.,3.,1.,1.,1.,1.,1.,1., 0000001P0000001
+0.,0.,0.,-0.388888889,0.5,0.,-0.166666667,1.166666667,0.,        0000001P0000002
+1.166666667,1.166666667,0.,1.388888889,0.5,-0.,1.,0.,0.,0.,3.,   0000001P0000003
+-0.,-0.,1.;                                                      0000001P0000004
+S      1G      4D      2P      4                                        T0000001
diff --git a/tests/opencascade/iges_write.cc b/tests/opencascade/iges_write.cc
new file mode 100644 (file)
index 0000000..6430b15
--- /dev/null
@@ -0,0 +1,55 @@
+
+//----------------------------  iges_read.cc  ---------------------------
+//    $Id: testsuite.html 13373 2006-07-13 13:12:08Z kanschat $
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005 by the deal.II authors 
+//
+//    This file is subject to QPL 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.
+//
+//----------------------------  iges_read.cc  ---------------------------
+
+
+// Read goteborg.iges and dump its topological structure to the logfile.
+
+#include "../tests.h"
+#include <fstream>
+#include <base/logstream.h>
+
+#include <deal.II/grid/occ_utilities.h>
+#include <TopTools.hxx>
+#include <TopoDS_Shape.hxx>
+#include <Standard_Stream.hxx>
+
+using namespace OpenCASCADE;
+
+int main () 
+{
+  // std::ofstream logfile("output");
+  // deallog.attach(logfile);
+  // deallog.depth_console(0);
+  
+  TopoDS_Shape sh = read_IGES(SOURCE_DIR "/iges_files/wigley.iges");
+  unsigned int nf=0, ne=0, nv=0;
+  count_elements(sh, nf, ne, nv);
+  // deallog << "Shape contains " << nf << " faces, "
+  //     << ne << " edges, and " 
+  //     << nv << " vertices." << std::endl;
+
+  write_IGES(sh, "output");
+
+  // try 
+  //   {
+  //     TopoDS_Shape sh_fail = read_IGES("iges_files/nonexistent.iges");
+  //   }
+  // catch(...)
+  //   {
+  //     deallog << "Missing file correctly threw an exception." << std::endl;
+  //   }
+  
+  return 0;
+}
+                  
diff --git a/tests/opencascade/iges_write.output b/tests/opencascade/iges_write.output
new file mode 100644 (file)
index 0000000..b7fe83a
--- /dev/null
@@ -0,0 +1,93 @@
+                                                                        S0000001
+,,31HOpen CASCADE IGES processor 6.7,13HFilename.iges,                  G0000001
+16HOpen CASCADE 6.7,31HOpen CASCADE IGES processor 6.7,32,308,15,308,15,G0000002
+,1.,2,2HMM,1,0.01,15H20140813.132822,1E-07,1.25,6Hheltai,,11,0,         G0000003
+15H20140813.132822,;                                                    G0000004
+     144       1       0       0       0       0       0       000000000D0000001
+     144       0       0       1       0                               0D0000002
+     128       2       0       0       0       0       0       000010000D0000003
+     128       0       0      29       0                               0D0000004
+     142      31       0       0       0       0       0       000010500D0000005
+     142       0       0       1       0                               0D0000006
+     102      32       0       0       0       0       0       000010000D0000007
+     102       0       0       1       0                               0D0000008
+     110      33       0       0       0       0       0       000010000D0000009
+     110       0       0       1       0                               0D0000010
+     110      34       0       0       0       0       0       000010000D0000011
+     110       0       0       1       0                               0D0000012
+     110      35       0       0       0       0       0       000010000D0000013
+     110       0       0       1       0                               0D0000014
+     110      36       0       0       0       0       0       000010000D0000015
+     110       0       0       1       0                               0D0000016
+     102      37       0       0       0       0       0       000010000D0000017
+     102       0       0       1       0                               0D0000018
+     126      38       0       0       0       0       0       000010000D0000019
+     126       0       0       7       0                               0D0000020
+     126      45       0       0       0       0       0       000010000D0000021
+     126       0       0       4       0                               0D0000022
+     126      49       0       0       0       0       0       000010000D0000023
+     126       0       0      10       0                               0D0000024
+     126      59       0       0       0       0       0       000010000D0000025
+     126       0       0       3       0                               0D0000026
+144,3,1,0,5;                                                     0000001P0000001
+128,3,10,3,4,0,0,1,0,0,0.,0.,0.,0.,1.,1.,1.,1.,0.,0.,0.,0.,0.,   0000003P0000002
+0.434398431,0.434398431,0.434398431,0.67839972,0.67839972,       0000003P0000003
+0.67839972,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,   0000003P0000004
+1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,  0000003P0000005
+1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,-1.25,0.,0.15625,-0.427535926,  0000003P0000006
+0.166356581,0.15625,0.427535926,0.166356581,0.15625,1.25,        0000003P0000007
+-3.885780586E-16,0.15625,-1.25,0.,0.1171875,-0.427535926,        0000003P0000008
+0.166356581,0.1171875,0.427535926,0.166356581,0.1171875,1.25,    0000003P0000009
+-3.885780586E-16,0.1171875,-1.25,0.,7.8125E-02,-0.427535926,     0000003P0000010
+0.166356581,7.8125E-02,0.427535926,0.166356581,7.8125E-02,1.25,  0000003P0000011
+-3.885780586E-16,7.8125E-02,-1.25,0.,3.90625E-02,-0.427535926,   0000003P0000012
+0.166356581,3.90625E-02,0.427535926,0.166356581,3.90625E-02,     0000003P0000013
+1.25,-3.885780586E-16,3.90625E-02,-1.25,0.,-2.194137841E-02,     0000003P0000014
+-0.427537148,0.166340839,-2.194137841E-02,0.427537148,           0000003P0000015
+0.166340839,-2.194137841E-02,1.25,-3.885524483E-16,              0000003P0000016
+-2.194137841E-02,-1.25,0.,-4.186850308E-02,-0.426411306,         0000003P0000017
+0.157707663,-4.186850308E-02,0.426411306,0.157707663,            0000003P0000018
+-4.186850308E-02,1.25,-3.683109958E-16,-4.186850308E-02,-1.25,   0000003P0000019
+0.,-6.051483061E-02,-0.424671145,0.14360916,-6.051483061E-02,    0000003P0000020
+0.424671145,0.14360916,-6.051483061E-02,1.25,-3.352606389E-16,   0000003P0000021
+-6.051483061E-02,-1.25,0.,-0.101335678,-0.420417595,0.100130616, 0000003P0000022
+-0.101335678,0.420417595,0.100130616,-0.101335678,1.25,          0000003P0000023
+-2.335884101E-16,-0.101335678,-1.25,0.,-0.121016618,             0000003P0000024
+-0.418058171,6.969502649E-02,-0.121016618,0.418058171,           0000003P0000025
+6.969502649E-02,-0.121016618,1.25,-1.624730779E-16,-0.121016618, 0000003P0000026
+-1.25,0.,-0.139275692,-0.416669646,3.62728606E-02,-0.139275692,  0000003P0000027
+0.416669646,3.62728606E-02,-0.139275692,1.25,-8.457292169E-17,   0000003P0000028
+-0.139275692,-1.25,0.,-0.15625,-0.416666667,0.,-0.15625,         0000003P0000029
+0.416666667,0.,-0.15625,1.25,0.,-0.15625,0.,1.,0.,1.;            0000003P0000030
+142,0,3,7,17,3;                                                  0000005P0000031
+102,4,9,11,13,15;                                                0000007P0000032
+110,0.,1.,0.,0.,0.,0.;                                           0000009P0000033
+110,0.,0.,0.,1.,0.,0.;                                           0000011P0000034
+110,1.,0.,0.,1.,1.,0.;                                           0000013P0000035
+110,1.,1.,0.,0.,1.,0.;                                           0000015P0000036
+102,4,19,21,23,25;                                               0000017P0000037
+126,10,4,0,0,1,0,0.,0.,0.,0.,0.,0.32160028,0.32160028,           0000019P0000038
+0.32160028,0.565601569,0.565601569,0.565601569,1.,1.,1.,1.,1.,   0000019P0000039
+1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,-1.25,0.,-0.15625,-1.25,0.,     0000019P0000040
+-0.139275692,-1.25,0.,-0.121016618,-1.25,0.,-0.101335678,-1.25,  0000019P0000041
+0.,-6.051483061E-02,-1.25,0.,-4.186850308E-02,-1.25,0.,          0000019P0000042
+-2.194137841E-02,-1.25,0.,3.90625E-02,-1.25,0.,7.8125E-02,-1.25, 0000019P0000043
+0.,0.1171875,-1.25,0.,0.15625,0.,1.,0.,0.,1.;                    0000019P0000044
+126,3,3,1,0,1,0,0.,0.,0.,0.,1.,1.,1.,1.,1.,1.,1.,1.,-1.25,0.,    0000021P0000045
+0.15625,-0.427535926,0.166356581,0.15625,0.427535926,            0000021P0000046
+0.166356581,0.15625,1.25,-3.885780586E-16,0.15625,0.,1.,-0.,     0000021P0000047
+4.972885125E-17,1.;                                              0000021P0000048
+126,10,4,0,0,1,0,0.,0.,0.,0.,0.,0.434398431,0.434398431,         0000023P0000049
+0.434398431,0.67839972,0.67839972,0.67839972,1.,1.,1.,1.,1.,1.,  0000023P0000050
+1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.25,-3.885780586E-16,0.15625,     0000023P0000051
+1.25,-3.885780586E-16,0.1171875,1.25,-3.885780586E-16,           0000023P0000052
+7.8125E-02,1.25,-3.885780586E-16,3.90625E-02,1.25,               0000023P0000053
+-3.885524483E-16,-2.194137841E-02,1.25,-3.683109958E-16,         0000023P0000054
+-4.186850308E-02,1.25,-3.352606389E-16,-6.051483061E-02,1.25,    0000023P0000055
+-2.335884101E-16,-0.101335678,1.25,-1.624730779E-16,             0000023P0000056
+-0.121016618,1.25,-8.457292169E-17,-0.139275692,1.25,0.,         0000023P0000057
+-0.15625,0.,1.,0.,0.,1.;                                         0000023P0000058
+126,3,3,0,0,1,0,0.,0.,0.,0.,1.,1.,1.,1.,1.,1.,1.,1.,1.25,0.,     0000025P0000059
+-0.15625,0.416666667,0.,-0.15625,-0.416666667,0.,-0.15625,-1.25, 0000025P0000060
+0.,-0.15625,0.,1.,0.,0.,1.;                                      0000025P0000061
+S      1G      4D     26P     61                                        T0000001

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.