Geometry.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef PART_GEOMETRY_H
00025 #define PART_GEOMETRY_H
00026
00027 #include <Handle_Geom_CartesianPoint.hxx>
00028 #include <Handle_Geom_BezierCurve.hxx>
00029 #include <Handle_Geom_BSplineCurve.hxx>
00030 #include <Handle_Geom_Circle.hxx>
00031 #include <Handle_Geom_Ellipse.hxx>
00032 #include <Handle_Geom_Hyperbola.hxx>
00033 #include <Handle_Geom_Parabola.hxx>
00034 #include <Handle_Geom_Line.hxx>
00035 #include <Handle_Geom_OffsetCurve.hxx>
00036 #include <Handle_Geom_TrimmedCurve.hxx>
00037 #include <Handle_Geom_Surface.hxx>
00038 #include <Handle_Geom_BezierSurface.hxx>
00039 #include <Handle_Geom_BSplineSurface.hxx>
00040 #include <Handle_Geom_CylindricalSurface.hxx>
00041 #include <Handle_Geom_ConicalSurface.hxx>
00042 #include <Handle_Geom_SphericalSurface.hxx>
00043 #include <Handle_Geom_ToroidalSurface.hxx>
00044 #include <Handle_Geom_Plane.hxx>
00045 #include <Handle_Geom_OffsetSurface.hxx>
00046 #include <Handle_Geom_RectangularTrimmedSurface.hxx>
00047 #include <Handle_Geom_SurfaceOfRevolution.hxx>
00048 #include <Handle_Geom_SurfaceOfLinearExtrusion.hxx>
00049 #include <TopoDS_Shape.hxx>
00050 #include <gp_Ax1.hxx>
00051 #include <gp_Dir.hxx>
00052 #include <Base/Persistence.h>
00053 #include <Base/Vector3D.h>
00054
00055 namespace Part {
00056
00057 class PartExport Geometry: public Base::Persistence
00058 {
00059 TYPESYSTEM_HEADER();
00060 public:
00061 virtual ~Geometry();
00062
00063 virtual TopoDS_Shape toShape() const = 0;
00064 virtual const Handle_Geom_Geometry& handle() const = 0;
00065
00066 virtual unsigned int getMemSize(void) const;
00067 virtual void Save(Base::Writer &) const;
00068 virtual void Restore(Base::XMLReader &);
00070 virtual Geometry *clone(void) const = 0;
00072 bool Construction;
00073
00074 protected:
00075 Geometry();
00076
00077 private:
00078 Geometry(const Geometry&);
00079 Geometry& operator = (const Geometry&);
00080 };
00081
00082 class PartExport GeomPoint : public Geometry
00083 {
00084 TYPESYSTEM_HEADER();
00085 public:
00086 GeomPoint();
00087 GeomPoint(const Handle_Geom_CartesianPoint&);
00088 GeomPoint(const Base::Vector3d&);
00089 virtual ~GeomPoint();
00090 virtual Geometry *clone(void) const;
00091 virtual TopoDS_Shape toShape() const;
00092
00093
00094 virtual unsigned int getMemSize(void) const;
00095 virtual void Save(Base::Writer &) const;
00096 virtual void Restore(Base::XMLReader &);
00097
00098 virtual PyObject *getPyObject(void);
00099
00100 const Handle_Geom_Geometry& handle() const;
00101
00102 Base::Vector3d getPoint(void)const;
00103 void setPoint(const Base::Vector3d&);
00104
00105 private:
00106 Handle_Geom_CartesianPoint myPoint;
00107 };
00108
00109 class PartExport GeomCurve : public Geometry
00110 {
00111 TYPESYSTEM_HEADER();
00112 public:
00113 GeomCurve();
00114 virtual ~GeomCurve();
00115
00116 TopoDS_Shape toShape() const;
00117 bool tangent(double u, gp_Dir&) const;
00118 };
00119
00120 class PartExport GeomBezierCurve : public GeomCurve
00121 {
00122 TYPESYSTEM_HEADER();
00123 public:
00124 GeomBezierCurve();
00125 GeomBezierCurve(const Handle_Geom_BezierCurve&);
00126 virtual ~GeomBezierCurve();
00127 virtual Geometry *clone(void) const;
00128
00129
00130 virtual unsigned int getMemSize (void) const;
00131 virtual void Save (Base::Writer &) const;
00132 virtual void Restore(Base::XMLReader &);
00133
00134 virtual PyObject *getPyObject(void);
00135
00136 void setHandle(const Handle_Geom_BezierCurve&);
00137 const Handle_Geom_Geometry& handle() const;
00138
00139 private:
00140 Handle_Geom_BezierCurve myCurve;
00141 };
00142
00143 class PartExport GeomBSplineCurve : public GeomCurve
00144 {
00145 TYPESYSTEM_HEADER();
00146 public:
00147 GeomBSplineCurve();
00148 GeomBSplineCurve(const Handle_Geom_BSplineCurve&);
00149 virtual ~GeomBSplineCurve();
00150 virtual Geometry *clone(void) const;
00151
00152 int countPoles() const;
00153 void setPole(int index, const Base::Vector3d&, double weight=-1);
00154 std::vector<Base::Vector3d> getPoles() const;
00155 bool join(const Handle_Geom_BSplineCurve&);
00156 void makeC1Continuous(double, double);
00157
00158
00159 virtual unsigned int getMemSize(void) const;
00160 virtual void Save(Base::Writer &) const;
00161 virtual void Restore(Base::XMLReader &);
00162
00163 virtual PyObject *getPyObject(void);
00164
00165 void setHandle(const Handle_Geom_BSplineCurve&);
00166 const Handle_Geom_Geometry& handle() const;
00167
00168 private:
00169 Handle_Geom_BSplineCurve myCurve;
00170 };
00171
00172 class PartExport GeomCircle : public GeomCurve
00173 {
00174 TYPESYSTEM_HEADER();
00175 public:
00176 GeomCircle();
00177 GeomCircle(const Handle_Geom_Circle&);
00178 virtual ~GeomCircle();
00179 virtual Geometry *clone(void) const;
00180
00181 Base::Vector3d getCenter(void) const;
00182 double getRadius(void) const;
00183 void setCenter(const Base::Vector3d& Center);
00184 void setRadius(double Radius);
00185
00186
00187 virtual unsigned int getMemSize(void) const;
00188 virtual void Save(Base::Writer &) const;
00189 virtual void Restore(Base::XMLReader &);
00190
00191 virtual PyObject *getPyObject(void);
00192
00193 const Handle_Geom_Geometry& handle() const;
00194
00195 private:
00196 Handle_Geom_Circle myCurve;
00197 };
00198
00199 class PartExport GeomArcOfCircle : public GeomCurve
00200 {
00201 TYPESYSTEM_HEADER();
00202 public:
00203 GeomArcOfCircle();
00204 GeomArcOfCircle(const Handle_Geom_Circle&);
00205 virtual ~GeomArcOfCircle();
00206 virtual Geometry *clone(void) const;
00207
00208 Base::Vector3d getStartPoint() const;
00209 Base::Vector3d getEndPoint() const;
00210
00211 Base::Vector3d getCenter(void) const;
00212 double getRadius(void) const;
00213 void setCenter(const Base::Vector3d& Center);
00214 void setRadius(double Radius);
00215 void getRange(double& u, double& v) const;
00216 void setRange(double u, double v);
00217
00218
00219 virtual unsigned int getMemSize(void) const;
00220 virtual void Save(Base::Writer &) const;
00221 virtual void Restore(Base::XMLReader &);
00222
00223 virtual PyObject *getPyObject(void);
00224
00225 void setHandle(const Handle_Geom_TrimmedCurve&);
00226 const Handle_Geom_Geometry& handle() const;
00227
00228 private:
00229 Handle_Geom_TrimmedCurve myCurve;
00230 };
00231
00232 class PartExport GeomEllipse : public GeomCurve
00233 {
00234 TYPESYSTEM_HEADER();
00235 public:
00236 GeomEllipse();
00237 GeomEllipse(const Handle_Geom_Ellipse&);
00238 virtual ~GeomEllipse();
00239 virtual Geometry *clone(void) const;
00240
00241
00242 virtual unsigned int getMemSize(void) const;
00243 virtual void Save(Base::Writer &) const;
00244 virtual void Restore(Base::XMLReader &);
00245
00246 virtual PyObject *getPyObject(void);
00247
00248 const Handle_Geom_Geometry& handle() const;
00249
00250 private:
00251 Handle_Geom_Ellipse myCurve;
00252 };
00253
00254 class PartExport GeomHyperbola : public GeomCurve
00255 {
00256 TYPESYSTEM_HEADER();
00257 public:
00258 GeomHyperbola();
00259 GeomHyperbola(const Handle_Geom_Hyperbola&);
00260 virtual ~GeomHyperbola();
00261 virtual Geometry *clone(void) const;
00262
00263
00264 virtual unsigned int getMemSize(void) const;
00265 virtual void Save(Base::Writer &) const;
00266 virtual void Restore(Base::XMLReader &);
00267
00268 virtual PyObject *getPyObject(void);
00269
00270 const Handle_Geom_Geometry& handle() const;
00271
00272 private:
00273 Handle_Geom_Hyperbola myCurve;
00274 };
00275
00276 class PartExport GeomParabola : public GeomCurve
00277 {
00278 TYPESYSTEM_HEADER();
00279 public:
00280 GeomParabola();
00281 GeomParabola(const Handle_Geom_Parabola&);
00282 virtual ~GeomParabola();
00283 virtual Geometry *clone(void) const;
00284
00285
00286 virtual unsigned int getMemSize(void) const;
00287 virtual void Save(Base::Writer &) const;
00288 virtual void Restore(Base::XMLReader &);
00289
00290 virtual PyObject *getPyObject(void);
00291
00292 const Handle_Geom_Geometry& handle() const;
00293
00294 private:
00295 Handle_Geom_Parabola myCurve;
00296 };
00297
00298 class PartExport GeomLine : public GeomCurve
00299 {
00300 TYPESYSTEM_HEADER();
00301 public:
00302 GeomLine();
00303 GeomLine(const Handle_Geom_Line&);
00304 GeomLine(const Base::Vector3d& Pos, const Base::Vector3d& Dir);
00305 virtual ~GeomLine();
00306 virtual Geometry *clone(void) const;
00307
00308 void setLine(const Base::Vector3d& Pos, const Base::Vector3d& Dir);
00309 Base::Vector3d getPos(void) const;
00310 Base::Vector3d getDir(void) const;
00311
00312
00313 virtual unsigned int getMemSize(void) const;
00314 virtual void Save(Base::Writer &) const;
00315 virtual void Restore(Base::XMLReader &);
00316
00317 virtual PyObject *getPyObject(void);
00318
00319 const Handle_Geom_Geometry& handle() const;
00320
00321 private:
00322 Handle_Geom_Line myCurve;
00323 };
00324
00325 class PartExport GeomLineSegment : public GeomCurve
00326 {
00327 TYPESYSTEM_HEADER();
00328 public:
00329 GeomLineSegment();
00330 virtual ~GeomLineSegment();
00331 virtual Geometry *clone(void) const;
00332
00333 Base::Vector3d getStartPoint() const;
00334 Base::Vector3d getEndPoint() const;
00335
00336 void setPoints(const Base::Vector3d& p1,
00337 const Base::Vector3d& p2);
00338
00339
00340 virtual unsigned int getMemSize(void) const;
00341 virtual void Save(Base::Writer &) const;
00342 virtual void Restore(Base::XMLReader &);
00343
00344 virtual PyObject *getPyObject(void);
00345
00346 void setHandle(const Handle_Geom_TrimmedCurve&);
00347 const Handle_Geom_Geometry& handle() const;
00348
00349 private:
00350 Handle_Geom_TrimmedCurve myCurve;
00351 };
00352
00353 class PartExport GeomOffsetCurve : public GeomCurve
00354 {
00355 TYPESYSTEM_HEADER();
00356 public:
00357 GeomOffsetCurve();
00358 GeomOffsetCurve(const Handle_Geom_Curve&, double, const gp_Dir&);
00359 GeomOffsetCurve(const Handle_Geom_OffsetCurve&);
00360 virtual ~GeomOffsetCurve();
00361 virtual Geometry *clone(void) const;
00362
00363
00364 virtual unsigned int getMemSize(void) const;
00365 virtual void Save(Base::Writer &) const;
00366 virtual void Restore(Base::XMLReader &);
00367
00368 virtual PyObject *getPyObject(void);
00369
00370 void setHandle(const Handle_Geom_OffsetCurve& c);
00371 const Handle_Geom_Geometry& handle() const;
00372
00373 private:
00374 Handle_Geom_OffsetCurve myCurve;
00375 };
00376
00377 class PartExport GeomTrimmedCurve : public GeomCurve
00378 {
00379 TYPESYSTEM_HEADER();
00380 public:
00381 GeomTrimmedCurve();
00382 GeomTrimmedCurve(const Handle_Geom_TrimmedCurve&);
00383 virtual ~GeomTrimmedCurve();
00384 virtual Geometry *clone(void) const;
00385
00386
00387 virtual unsigned int getMemSize(void) const;
00388 virtual void Save(Base::Writer &) const;
00389 virtual void Restore(Base::XMLReader &);
00390
00391 virtual PyObject *getPyObject(void);
00392
00393 void setHandle(const Handle_Geom_TrimmedCurve&);
00394 const Handle_Geom_Geometry& handle() const;
00395
00396 private:
00397 Handle_Geom_TrimmedCurve myCurve;
00398 };
00399
00400 class PartExport GeomSurface : public Geometry
00401 {
00402 TYPESYSTEM_HEADER();
00403 public:
00404 GeomSurface();
00405 virtual ~GeomSurface();
00406
00407 TopoDS_Shape toShape() const;
00408 bool tangentU(double u, double v, gp_Dir& dirU) const;
00409 bool tangentV(double u, double v, gp_Dir& dirV) const;
00410 };
00411
00412 class PartExport GeomBezierSurface : public GeomSurface
00413 {
00414 TYPESYSTEM_HEADER();
00415 public:
00416 GeomBezierSurface();
00417 GeomBezierSurface(const Handle_Geom_BezierSurface&);
00418 virtual ~GeomBezierSurface();
00419 virtual Geometry *clone(void) const;
00420
00421
00422 virtual unsigned int getMemSize(void) const;
00423 virtual void Save(Base::Writer &) const;
00424 virtual void Restore(Base::XMLReader &);
00425
00426 virtual PyObject *getPyObject(void);
00427
00428
00429 const Handle_Geom_Geometry& handle() const;
00430
00431 private:
00432 Handle_Geom_BezierSurface mySurface;
00433 };
00434
00435 class PartExport GeomBSplineSurface : public GeomSurface
00436 {
00437 TYPESYSTEM_HEADER();
00438 public:
00439 GeomBSplineSurface();
00440 GeomBSplineSurface(const Handle_Geom_BSplineSurface&);
00441 virtual ~GeomBSplineSurface();
00442 virtual Geometry *clone(void) const;
00443
00444
00445 virtual unsigned int getMemSize(void) const;
00446 virtual void Save(Base::Writer &) const;
00447 virtual void Restore(Base::XMLReader &);
00448
00449 virtual PyObject *getPyObject(void);
00450
00451 const Handle_Geom_Geometry& handle() const;
00452
00453 private:
00454 Handle_Geom_BSplineSurface mySurface;
00455 };
00456
00457 class PartExport GeomCylinder : public GeomSurface
00458 {
00459 TYPESYSTEM_HEADER();
00460 public:
00461 GeomCylinder();
00462 virtual ~GeomCylinder();
00463 virtual Geometry *clone(void) const;
00464
00465
00466 virtual unsigned int getMemSize(void) const;
00467 virtual void Save(Base::Writer &) const;
00468 virtual void Restore(Base::XMLReader &);
00469
00470 virtual PyObject *getPyObject(void);
00471
00472 const Handle_Geom_Geometry& handle() const;
00473
00474 private:
00475 Handle_Geom_CylindricalSurface mySurface;
00476 };
00477
00478 class PartExport GeomCone : public GeomSurface
00479 {
00480 TYPESYSTEM_HEADER();
00481 public:
00482 GeomCone();
00483 virtual ~GeomCone();
00484 virtual Geometry *clone(void) const;
00485
00486
00487 virtual unsigned int getMemSize(void) const;
00488 virtual void Save(Base::Writer &) const;
00489 virtual void Restore(Base::XMLReader &);
00490
00491 virtual PyObject *getPyObject(void);
00492
00493 const Handle_Geom_Geometry& handle() const;
00494
00495 private:
00496 Handle_Geom_ConicalSurface mySurface;
00497 };
00498
00499 class PartExport GeomSphere : public GeomSurface
00500 {
00501 TYPESYSTEM_HEADER();
00502 public:
00503 GeomSphere();
00504 virtual ~GeomSphere();
00505 virtual Geometry *clone(void) const;
00506
00507
00508 virtual unsigned int getMemSize(void) const;
00509 virtual void Save(Base::Writer &) const;
00510 virtual void Restore(Base::XMLReader &);
00511
00512 virtual PyObject *getPyObject(void);
00513
00514 const Handle_Geom_Geometry& handle() const;
00515
00516 private:
00517 Handle_Geom_SphericalSurface mySurface;
00518 };
00519
00520 class PartExport GeomToroid : public GeomSurface
00521 {
00522 TYPESYSTEM_HEADER();
00523 public:
00524 GeomToroid();
00525 virtual ~GeomToroid();
00526 virtual Geometry *clone(void) const;
00527
00528
00529 virtual unsigned int getMemSize(void) const;
00530 virtual void Save(Base::Writer &) const;
00531 virtual void Restore(Base::XMLReader &);
00532
00533 virtual PyObject *getPyObject(void);
00534
00535 const Handle_Geom_Geometry& handle() const;
00536
00537 private:
00538 Handle_Geom_ToroidalSurface mySurface;
00539 };
00540
00541 class PartExport GeomPlane : public GeomSurface
00542 {
00543 TYPESYSTEM_HEADER();
00544 public:
00545 GeomPlane();
00546 virtual ~GeomPlane();
00547 virtual Geometry *clone(void) const;
00548
00549
00550 virtual unsigned int getMemSize(void) const;
00551 virtual void Save(Base::Writer &) const;
00552 virtual void Restore(Base::XMLReader &);
00553
00554 virtual PyObject *getPyObject(void);
00555
00556 const Handle_Geom_Geometry& handle() const;
00557
00558 private:
00559 Handle_Geom_Plane mySurface;
00560 };
00561
00562 class PartExport GeomOffsetSurface : public GeomSurface
00563 {
00564 TYPESYSTEM_HEADER();
00565 public:
00566 GeomOffsetSurface();
00567 GeomOffsetSurface(const Handle_Geom_Surface&, double);
00568 GeomOffsetSurface(const Handle_Geom_OffsetSurface&);
00569 virtual ~GeomOffsetSurface();
00570 virtual Geometry *clone(void) const;
00571
00572
00573 virtual unsigned int getMemSize(void) const;
00574 virtual void Save(Base::Writer &) const;
00575 virtual void Restore(Base::XMLReader &);
00576
00577 virtual PyObject *getPyObject(void);
00578
00579 void setHandle(const Handle_Geom_OffsetSurface& s);
00580 const Handle_Geom_Geometry& handle() const;
00581
00582 private:
00583 Handle_Geom_OffsetSurface mySurface;
00584 };
00585
00586 class PartExport GeomTrimmedSurface : public GeomSurface
00587 {
00588 TYPESYSTEM_HEADER();
00589 public:
00590 GeomTrimmedSurface();
00591 GeomTrimmedSurface(const Handle_Geom_RectangularTrimmedSurface&);
00592 virtual ~GeomTrimmedSurface();
00593 virtual Geometry *clone(void) const;
00594
00595
00596 virtual unsigned int getMemSize(void) const;
00597 virtual void Save(Base::Writer &) const;
00598 virtual void Restore(Base::XMLReader &);
00599
00600 virtual PyObject *getPyObject(void);
00601
00602 void setHandle(const Handle_Geom_RectangularTrimmedSurface& s);
00603 const Handle_Geom_Geometry& handle() const;
00604
00605 private:
00606 Handle_Geom_RectangularTrimmedSurface mySurface;
00607 };
00608
00609 class PartExport GeomSurfaceOfRevolution : public GeomSurface
00610 {
00611 TYPESYSTEM_HEADER();
00612 public:
00613 GeomSurfaceOfRevolution();
00614 GeomSurfaceOfRevolution(const Handle_Geom_Curve&, const gp_Ax1&);
00615 GeomSurfaceOfRevolution(const Handle_Geom_SurfaceOfRevolution&);
00616 virtual ~GeomSurfaceOfRevolution();
00617 virtual Geometry *clone(void) const;
00618
00619
00620 virtual unsigned int getMemSize(void) const;
00621 virtual void Save(Base::Writer &) const;
00622 virtual void Restore(Base::XMLReader &);
00623
00624 virtual PyObject *getPyObject(void);
00625
00626 void setHandle(const Handle_Geom_SurfaceOfRevolution& c);
00627 const Handle_Geom_Geometry& handle() const;
00628
00629 private:
00630 Handle_Geom_SurfaceOfRevolution mySurface;
00631 };
00632
00633 class PartExport GeomSurfaceOfExtrusion : public GeomSurface
00634 {
00635 TYPESYSTEM_HEADER();
00636 public:
00637 GeomSurfaceOfExtrusion();
00638 GeomSurfaceOfExtrusion(const Handle_Geom_Curve&, const gp_Dir&);
00639 GeomSurfaceOfExtrusion(const Handle_Geom_SurfaceOfLinearExtrusion&);
00640 virtual ~GeomSurfaceOfExtrusion();
00641 virtual Geometry *clone(void) const;
00642
00643
00644 virtual unsigned int getMemSize(void) const;
00645 virtual void Save(Base::Writer &) const;
00646 virtual void Restore(Base::XMLReader &);
00647
00648 virtual PyObject *getPyObject(void);
00649
00650 void setHandle(const Handle_Geom_SurfaceOfLinearExtrusion& c);
00651 const Handle_Geom_Geometry& handle() const;
00652
00653 private:
00654 Handle_Geom_SurfaceOfLinearExtrusion mySurface;
00655 };
00656
00657
00658
00659 PartExport
00660 bool find2DLinesIntersection(const Base::Vector3d &orig1, const Base::Vector3d &dir1,
00661 const Base::Vector3d &orig2, const Base::Vector3d &dir2,
00662 Base::Vector3d &point);
00663 PartExport
00664 bool find2DLinesIntersection(const GeomLineSegment *lineSeg1, const GeomLineSegment *lineSeg2,
00665 Base::Vector3d &point);
00666 PartExport
00667 bool findFilletCenter(const GeomLineSegment *lineSeg1, const GeomLineSegment *lineSeg2, double radius,
00668 Base::Vector3d ¢er);
00669 PartExport
00670 bool findFilletCenter(const GeomLineSegment *lineSeg1, const GeomLineSegment *lineSeg2, double radius,
00671 const Base::Vector3d& refPnt1, const Base::Vector3d& refPnt2,
00672 Base::Vector3d ¢er);
00673 PartExport
00674 double suggestFilletRadius(const GeomLineSegment *lineSeg1, const GeomLineSegment *lineSeg2,
00675 const Base::Vector3d &refPnt1, const Base::Vector3d &refPnt2);
00676 PartExport
00677 GeomArcOfCircle *createFilletGeometry(const GeomLineSegment *lineSeg1, const GeomLineSegment *lineSeg2,
00678 const Base::Vector3d ¢er, double radius);
00679 }
00680
00681 #endif // PART_GEOMETRY_H