TopoShape.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) Jürgen Riegel          (juergen.riegel@web.de) 2002     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef PART_TOPOSHAPE_H
00025 #define PART_TOPOSHAPE_H
00026 
00027 #include <iostream>
00028 #include <gp_Pnt.hxx>
00029 #include <gp_Vec.hxx>
00030 #include <TopoDS_Compound.hxx>
00031 #include <TopoDS_Wire.hxx>
00032 #include <TopTools_ListOfShape.hxx>
00033 #include <App/ComplexGeoData.h>
00034 
00035 class gp_Ax2;
00036 
00037 namespace Base {
00038 // Specialization for gp_Pnt
00039 template <>
00040 struct vec_traits<gp_Pnt> {
00041     typedef gp_Pnt vec_type;
00042     typedef double float_type;
00043     vec_traits(const vec_type& v) : v(v){}
00044     inline float_type x() { return v.X(); }
00045     inline float_type y() { return v.Y(); }
00046     inline float_type z() { return v.Z(); }
00047 private:
00048     const vec_type& v;
00049 };
00050 // Specialization for gp_Vec
00051 template <>
00052 struct vec_traits<gp_Vec> {
00053     typedef gp_Vec vec_type;
00054     typedef double float_type;
00055     vec_traits(const vec_type& v) : v(v){}
00056     inline float_type x() { return v.X(); }
00057     inline float_type y() { return v.Y(); }
00058     inline float_type z() { return v.Z(); }
00059 private:
00060     const vec_type& v;
00061 };
00062 // Specialization for gp_Dir
00063 template <>
00064 struct vec_traits<gp_Dir> {
00065     typedef gp_Dir vec_type;
00066     typedef double float_type;
00067     vec_traits(const vec_type& v) : v(v){}
00068     inline float_type x() { return v.X(); }
00069     inline float_type y() { return v.Y(); }
00070     inline float_type z() { return v.Z(); }
00071 private:
00072     const vec_type& v;
00073 };
00074 }
00075 
00076 namespace Part
00077 {
00078 
00079 class PartExport ShapeSegment : public Data::Segment
00080 {
00081     TYPESYSTEM_HEADER();
00082 
00083 public:
00084     ShapeSegment(const TopoDS_Shape &ShapeIn):Shape(ShapeIn){}
00085     ShapeSegment(){}
00086     virtual std::string getName() const;
00087 
00088     TopoDS_Shape Shape;
00089 };
00090 
00091 
00092 
00095 class PartExport TopoShape : public Data::ComplexGeoData
00096 {
00097     TYPESYSTEM_HEADER();
00098 
00099 public:
00100     TopoShape();
00101     TopoShape(const TopoDS_Shape&);
00102     TopoShape(const TopoShape&);
00103     ~TopoShape();
00104 
00105     void operator = (const TopoShape&);
00106 
00109 
00110     void setTransform(const Base::Matrix4D& rclTrf);
00112     Base::Matrix4D getTransform(void) const;
00114     Base::BoundBox3d getBoundBox(void)const;
00116 
00123     virtual std::vector<const char*> getElementTypes(void) const;
00124     virtual unsigned long countSubElements(const char* Type) const;
00126     virtual Data::Segment* getSubElement(const char* Type, unsigned long) const;
00128     virtual void getLinesFromSubelement(
00129         const Data::Segment*,
00130         std::vector<Base::Vector3d> &Points,
00131         std::vector<Line> &lines) const;
00133     virtual void getFacesFromSubelement(
00134         const Data::Segment*,
00135         std::vector<Base::Vector3d> &Points,
00136         std::vector<Base::Vector3d> &PointNormals,
00137         std::vector<Facet> &faces) const;
00139 
00140     TopoDS_Shape getSubShape(const char* Type) const;
00141     unsigned long countSubShapes(const char* Type) const;
00143     PyObject * getPySubShape(const char* Type) const;
00144 
00147     void Save (Base::Writer &writer) const;
00148     void Restore(Base::XMLReader &reader);
00149 
00150     void SaveDocFile (Base::Writer &writer) const;
00151     void RestoreDocFile(Base::Reader &reader);
00152     unsigned int getMemSize (void) const;
00154 
00157     void read(const char *FileName);
00158     void write(const char *FileName) const;
00159     void importIges(const char *FileName);
00160     void importStep(const char *FileName);
00161     void importBrep(const char *FileName);
00162     void exportIges(const char *FileName) const;
00163     void exportStep(const char *FileName) const;
00164     void exportBrep(const char *FileName) const;
00165     void exportStl (const char *FileName) const;
00166     void exportFaceSet(double, double, std::ostream&) const;
00167     void exportLineSet(std::ostream&) const;
00169 
00172     bool isNull() const;
00173     bool isValid() const;
00174     bool analyze(std::ostream&) const;
00175     bool isClosed() const;
00177 
00180     TopoDS_Shape cut(TopoDS_Shape) const;
00181     TopoDS_Shape common(TopoDS_Shape) const;
00182     TopoDS_Shape fuse(TopoDS_Shape) const;
00183     TopoDS_Shape oldFuse(TopoDS_Shape) const;
00184     TopoDS_Shape section(TopoDS_Shape) const;
00185     std::list<TopoDS_Wire> slice(const Base::Vector3d&, double) const;
00186     TopoDS_Compound slices(const Base::Vector3d&, const std::vector<double>&) const;
00188 
00191     TopoDS_Shape makePipe(const TopoDS_Shape& profile) const;
00192     TopoDS_Shape makePipeShell(const TopTools_ListOfShape& profiles, const Standard_Boolean make_solid,
00193         const Standard_Boolean isFrenet = Standard_False) const;
00194     TopoDS_Shape makePrism(const gp_Vec&) const;
00195     TopoDS_Shape revolve(const gp_Ax1&, double d) const;
00196     TopoDS_Shape makeThickSolid(const TopTools_ListOfShape& remFace,
00197         Standard_Real offset, Standard_Real tolerance) const;
00198     TopoDS_Shape makeSweep(const TopoDS_Shape& profile, double, int) const;
00199     TopoDS_Shape makeTube(double radius, double tol) const;
00200     TopoDS_Shape makeTube() const;
00201     TopoDS_Shape makeHelix(Standard_Real pitch, Standard_Real height,
00202         Standard_Real radius, Standard_Real angle=0) const;
00203     TopoDS_Shape makeLoft(const TopTools_ListOfShape& profiles, Standard_Boolean isSolid,
00204         Standard_Boolean isRuled) const;
00205     TopoDS_Shape makeOffset(double offset, double tol,
00206         bool intersection = false, bool selfInter = false,
00207         short offsetMode = 0, short join = 0);
00209 
00212     void transformGeometry(const Base::Matrix4D &rclMat);
00213     TopoDS_Shape transformGShape(const Base::Matrix4D&) const;
00214     void transformShape(const Base::Matrix4D&);
00215     TopoDS_Shape mirror(const gp_Ax2&) const;
00216     TopoDS_Shape toNurbs() const;
00217     TopoDS_Shape replaceShape(const std::vector< std::pair<TopoDS_Shape,TopoDS_Shape> >& s) const;
00218     TopoDS_Shape removeShape(const std::vector<TopoDS_Shape>& s) const;
00219     void sewShape();
00220     bool fix(double, double, double);
00221     bool removeInternalWires(double);
00223 
00226     void getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &faces,
00227         float Accuracy, uint16_t flags=0) const;
00228     void setFaces(const std::vector<Base::Vector3d> &Points,
00229                   const std::vector<Facet> &faces, float Accuracy=1.0e-06);
00231 
00232     TopoDS_Shape _Shape;
00233 };
00234 
00235 } //namespace Part
00236 
00237 
00238 #endif // PART_TOPOSHAPE_H

Generated on Wed Nov 23 19:00:46 2011 for FreeCAD by  doxygen 1.6.1