CFx SDK Documentation  2023 SP0
FMContour2D.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2015, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2015 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #ifndef __FMCONTOUR2D_H__
25 #define __FMCONTOUR2D_H__
26 
27 #include "FMGeometry.h"
28 #include "FMContoursBase.h"
29 #include "FMSegment2D.h"
30 
34 namespace FacetModeler
35 {
36 
37 class IContour2D;
38 class IBulgeSeg2D;
39 class Profile2D;
40 
42 public:
43  virtual bool onLineSeg( int nSegment ) = 0;
44 
45  virtual bool onArcSeg( int nSegment, DeviationParams** ppDev ) = 0;
46 
47  virtual bool onArcStartPoint( int nSegment, const OdGePoint2d& pt, int nTotalPts ) = 0;
48 
49  virtual bool onArcPoint( int nSegment, const OdGePoint2d& pt ) = 0;
50 
51  virtual bool onArcEndPoint( int nSegment, const OdGePoint2d& pt ) = 0;
52 
53  virtual bool onCoincidentSeg( int nSegment ) = 0;
54 };
55 
74 class FMGEOMETRY_API Contour2D
75 {
76  public:
81 
87  explicit Contour2D( ContourImplClass eImplClass );
88 
92  explicit Contour2D( const IBulgeSeg2D& rSrcSeg,
93  ContourImplClass eImplClass = ecicSimple );
94 
101  Contour2D( const Contour2D& rSrcCont,
102  ContourImplClass eImplClass = ecicSimple );
103 
105  explicit Contour2D( const IContour2D& rSrcCont,
106  ContourImplClass eImplClass = ecicSimple );
107 
112 
117 
124  Contour2D& operator = ( const Contour2D& rSrcCont );
125 
127  Contour2D& operator = ( const IContour2D& rSrcCont );
128 
135  Contour2D& cloneFrom( const IContour2D& rSrcCont );
136 
147 
152 
156  void swap ( Contour2D& rAnother );
157 
161  bool isClosed() const;
162 
163  bool isEndsEqual(const OdGeTol& gTol = FMGeGbl::gTol) const;
164 
168  void setClosed( bool bClosed = true );
169 
173  bool isEmpty() const;
174 
179 
187 
191  bool hasArcs() const;
192 
201 
206  Segment2D& rSegment ) const;
207 
212  OdGePoint2d& ptStart,
213  OdGePoint2d& ptEnd,
214  double& dBulge ) const;
215 
220  OdGeLineSeg2d& geLine ) const;
221 
226  OdGeCircArc2d& geArc ) const;
227 
232  OdGePoint2d& ptPoint ) const;
233 
238  double& dBulge ) const;
239 
244  OdGePoint2d* pPoint, double* pBulge = 0, OdIntPtr* pMetadata = 0, OdUInt32* puRawFlags = 0 ) const;
245 
249  Result getInternalAngleAt( OdUInt32 iIndex, double & dAngle ) const;
250 
255  const OdGePoint2d& ptPoint );
256 
261  double dBulge );
262 
267  const OdGePoint2d& ptPoint, double dBulge );
268 
272  void reserveVertices( OdUInt32 iReservedSize );
273 
280  OdIntPtr metadataAt( OdUInt32 iIndex ) const;
281 
289  OdIntPtr iNewData );
290 
295  OdIntPtr iBitsToModify = (OdIntPtr)-1 );
296 
300  bool isHiddenAt( OdUInt32 iIndex ) const;
301 
306  bool bHidden = true );
307 
312 
317  FaceOrientation eOrientation );
318 
323  bool threatAsSmoothCurveAt( OdUInt32 iIndex ) const;
324 
329  void setThreatAsSmoothCurveAt( OdUInt32 iIndex, bool bSmooth );
330 
334  bool isExplodedArcAt( OdUInt32 iIndex ) const;
335 
340  bool bExplodedArc = true );
341 
348  OdUInt32 rawFlagsAt( OdUInt32 iIndex ) const;
349 
353  Result setRawFlagsAt( OdUInt32 iIndex, OdUInt32 iRawFlags );
354 
365  const OdGePoint2d& ptStart, double dBulge = 0.0, OdIntPtr uMetadata = 0, OdUInt32 uRawFlags = 0 );
366 
373  Result appendVertex( const OdGePoint2d& ptStart,
374  double dBulge = 0.0, OdIntPtr uMetadata = 0, OdUInt32 uRawFlags = 0 );
375 
379  Result appendVertex( const OdGePoint2d& ptStart,
380  const OdGePoint2d& ptMid, OdIntPtr uMetadata = 0, OdUInt32 uRawFlags = 0 );
381 
385  Result appendVertices( const OdGePoint2dArray & vecSource );
386 
397  bool bShiftToHit = false );
398 
409  bool bCloseGap = false, double dMaxGap = 1e99 );
410 
418 
422  inline double startParam() const
423  { return 0.0; };
424 
428  double endParam() const;
429 
430  // Returns true and a period value, if the contour is closed
431  // Returns false otherwise
432  //bool getPeriodParam( double & dPeriod ) const;
433 
440  Result getStartPoint( OdGePoint2d& ptPoint ) const;
441 
448  Result getEndPoint( OdGePoint2d & ptPoint ) const;
449 
453  double length() const;
454 
458  Result getTangent( double dParam,
459  OdGeVector2d& vTangent ) const;
460 
464  Result getTangentAtDist( double dDist,
465  OdGeVector2d& vTangent ) const;
466 
470  Result getPoint( double dParam,
471  OdGePoint2d& ptPoint ) const;
472 
476  Result getPointAtDist( double dDist,
477  OdGePoint2d& ptPoint ) const;
478 
482  Result getDistAtParam( double dParam,
483  double& dDist ) const;
484 
488  Result getParamAtDist( double dDist,
489  double& dParam ) const;
490 
491  //Result getParamAtPoint(const OdGePoint2d& ptPoint, double& dParam) const;
492  //Result getDistAtPoint (const OdGePoint2d& ptPoint, double& dDist) const;
493 
503  Result getNormalizedParam( double& dParam ) const;
504 
514  Result getNormalizedDist( double& dDist ) const;
515 
522  bool areEqualParams( double dParam1,
523  double dParam2, double dParamTol = 1e-10 ) const;
524 
531  bool areEqualDists( double dDist1,
532  double dDist2, double dTol = 1e-6/*FMGeGbl::gTol.equalPoint()*/ ) const;
533 
537  Result addExtents( OdGeExtents2d& extExtents ) const;
538 
546  double area() const;
547 
551  double signedArea() const;
552 
556  bool isConvex() const;
557 
565  bool isCCW() const;
566 
570  void makeCCW( bool bCCW = true );
571 
582  bool isOn( const OdGePoint2d& ptTest, double* pParam = 0,
583  const OdGeTol& gTol = FMGeGbl::gTol ) const;
584 
594  double nearestParam( const OdGePoint2d& ptTest,
595  OdGePoint2d* ptNearest = 0 ) const;
596 
607  bool contains( const OdGePoint2d& ptPoint, bool* pOnBorder = 0,
608  const OdGeTol& gTol = FMGeGbl::gTol ) const;
609 
624  bool isSelfIntersecting( const OdGeTol& gTol = FMGeGbl::gTol, bool bExcludeTouch = false ) const;
625 
636  bool isValidRegion( const OdGeTol& gTol = FMGeGbl::gTol ) const;
637 
638  bool isInsideContour(const Contour2D& c2dOuter, bool fAllowBordersTouch = false, const OdGeTol& gTol = FMGeGbl::gTol) const;
639 
650  OdUInt32 intersect( const Segment2D& rSegB,
651  std::vector< Intersection >& vecPoints,
652  const OdGeTol& gTol = FMGeGbl::gTol ) const;
653 
664  OdUInt32 intersect( const Contour2D& rContB,
665  std::vector< Intersection >& vecPoints,
666  const OdGeTol& gTol = FMGeGbl::gTol ) const;
667 
679  std::vector< Intersection >& vecPoints,
680  const OdGeTol& gTol = FMGeGbl::gTol ) const;
681 
685  Result transformBy( const OdGeMatrix2d& mMatrix,
686  const DeviationParams& devDeviation = FMGeGbl::gDefDev );
687 
691  void reverse();
692 
696  void deleteCoincident( const OdGeTol& gTol = FMGeGbl::gTol );
697 
704  void mergeSegments( int iMergeFlags = 0, const OdGeTol & gTol = FMGeGbl::gTol );
705 
710  Result explode( const DeviationParams& devDeviation = FMGeGbl::gDefDev, OdIntPtr uArcMetadata = 0);
711 
717  const DeviationParams& devDeviation = FMGeGbl::gDefDev, OdIntPtr uArcMetadata = 0 ) const;
718 
733  OdUInt32 createVertexAt( double dParam,
734  const OdGeTol& gTol = FMGeGbl::gTol );
735 
749  const OdGeTol & gTol = FMGeGbl::gTol );
750 
760  Result createVerticesAt( const std::vector<double> & vecParams,
761  const OdGeTol& gTol = FMGeGbl::gTol );
762 
770  Result getSubContour(double dStartParam, double dEndParam,
771  Contour2D & rSubContour, const OdGeTol & gTol = FMGeGbl::gTol ) const;
772 
773 
789  Result getOffsetProfile( double dOffset, Profile2D& rResult,
790  FilletType eFilletType = eftExtend,
791  const OdGeTol& gTol = FMGeGbl::gTol ) const;
792 
793  Result getProfileByOffsets( const std::vector< double >& adOffset,
794  Profile2D& rResult,
795  const OdGeTol& gTol = FMGeGbl::gTol ) const;
796 
797 
801  bool traverse( Contour2DTraversingReactor& reactor ) const;
802 
807 
808  public:
810  inline operator const IContour2D& () const
811  { return *m_pImpl; }
812 
814  inline operator IContour2D& ()
815  { return *m_pImpl; }
816 
818  inline const IContour2D & impl() const
819  { return *m_pImpl; }
820 
822  inline IContour2D & impl()
823  { return *m_pImpl; }
824 
825  private:
826  IContour2D* m_pImpl;
827 
828  public:
832  FMGEOMETRY_API_STATIC static const Contour2D kNull;
833 };
834 
848 class FMGEOMETRY_API CachedContour2D : public Contour2D
849 {
850  public:
855  : Contour2D( ecicCached )
856  { }
857 
862  : Contour2D( eImplClass )
863  { }
864 
868  CachedContour2D( const IBulgeSeg2D& rSrcSeg, ContourImplClass eImplClass = ecicCached )
869  : Contour2D( rSrcSeg, eImplClass )
870  { }
871 
875  CachedContour2D( const Contour2D & rSrcCont, ContourImplClass eImplClass = ecicCached )
876  : Contour2D( rSrcCont, eImplClass )
877  { }
878 
882  inline CachedContour2D& operator = ( const Contour2D& rSrcCont )
883  {
884  Contour2D::operator=(rSrcCont);
885  return *this;
886  };
887 
891  inline CachedContour2D& cloneFrom( const Contour2D& rSrcCont )
892  {
893  Contour2D::cloneFrom(rSrcCont);
894  return *this;
895  };
896 
901  {
902  Contour2D::reset(eImplClass);
903  return *this;
904  };
905 };
906 
907 
908 FMGEOMETRY_API void ExtendContourStart(Contour2D& rContour);
909 FMGEOMETRY_API void ExtendContourEnd(Contour2D& rContour);
910 
911 FMGEOMETRY_API void ExtendContour(Contour2D& rContour);
912 
913 FMGEOMETRY_API bool FindClosestIntToBaseStart(const Contour2D& cBase, const Contour2D& cCutter, Intersection& intClosest);
914 FMGEOMETRY_API bool FindClosestIntToBaseEnd(const Contour2D& cBase, const Contour2D& cCutter, Intersection& intClosest);
915 
916 FMGEOMETRY_API Intersection FindIntClosestToPt(const OdGePoint2d& ptBase, const std::vector< Intersection >& vecPoints);
917 FMGEOMETRY_API bool IsIntersectionCloserToPt(const OdGePoint2d& ptBase, const Intersection& intCurrent, const Intersection& intToCheck);
918 
919 }; // namespace AECContours
920 
921 #endif //__FMCONTOUR2D_H__
unsigned int OdUInt32
#define ODRX_ABSTRACT
ptrdiff_t OdIntPtr
CachedContour2D & cloneFrom(const Contour2D &rSrcCont)
Definition: FMContour2D.h:891
CachedContour2D & reset(ContourImplClass eImplClass=ecicUnknown)
Definition: FMContour2D.h:900
CachedContour2D(ContourImplClass eImplClass)
Definition: FMContour2D.h:861
CachedContour2D(const Contour2D &rSrcCont, ContourImplClass eImplClass=ecicCached)
Definition: FMContour2D.h:875
CachedContour2D(const IBulgeSeg2D &rSrcSeg, ContourImplClass eImplClass=ecicCached)
Definition: FMContour2D.h:868
Result setAllMetadata(OdIntPtr iNewData, OdIntPtr iBitsToModify=(OdIntPtr) -1)
void swap(Contour2D &rAnother)
OdIntPtr metadataAt(OdUInt32 iIndex) const
Contour2D(const Contour2D &rSrcCont, ContourImplClass eImplClass=ecicSimple)
Contour2D(const IBulgeSeg2D &rSrcSeg, ContourImplClass eImplClass=ecicSimple)
Result explodeTo(Contour2D &rDestCont, const DeviationParams &devDeviation=FMGeGbl::gDefDev, OdIntPtr uArcMetadata=0) const
void deleteCoincident(const OdGeTol &gTol=FMGeGbl::gTol)
double length() const
Result setMetadataAt(OdUInt32 iIndex, OdIntPtr iNewData)
OdUInt32 intersectLine(const OdGeLine2d &rLine, std::vector< Intersection > &vecPoints, const OdGeTol &gTol=FMGeGbl::gTol) const
const IContour2D & impl() const
DOM.
Definition: FMContour2D.h:818
Result createVerticesAt(const std::vector< double > &vecParams, const OdGeTol &gTol=FMGeGbl::gTol)
Result getLineSegAt(OdUInt32 iIndex, OdGeLineSeg2d &geLine) const
Contour2D(const IContour2D &rSrcCont, ContourImplClass eImplClass=ecicSimple)
DOM.
double startParam() const
Definition: FMContour2D.h:422
bool isHiddenAt(OdUInt32 iIndex) const
OdUInt32 intersect(const Segment2D &rSegB, std::vector< Intersection > &vecPoints, const OdGeTol &gTol=FMGeGbl::gTol) const
OdUInt32 rawFlagsAt(OdUInt32 iIndex) const
OdUInt32 createVertexAtDist(double dDist, const OdGeTol &gTol=FMGeGbl::gTol)
double endParam() const
bool threatAsSmoothCurveAt(OdUInt32 iIndex) const
bool isOn(const OdGePoint2d &ptTest, double *pParam=0, const OdGeTol &gTol=FMGeGbl::gTol) const
Result appendContour(const Contour2D &rCont, bool bCloseGap=false, double dMaxGap=1e99)
bool isInsideContour(const Contour2D &c2dOuter, bool fAllowBordersTouch=false, const OdGeTol &gTol=FMGeGbl::gTol) const
OdUInt32 intersect(const Contour2D &rContB, std::vector< Intersection > &vecPoints, const OdGeTol &gTol=FMGeGbl::gTol) const
Result transformBy(const OdGeMatrix2d &mMatrix, const DeviationParams &devDeviation=FMGeGbl::gDefDev)
Result getProfileByOffsets(const std::vector< double > &adOffset, Profile2D &rResult, const OdGeTol &gTol=FMGeGbl::gTol) const
Contour2D(const OdGeExtents2d &ext)
void reserveVertices(OdUInt32 iReservedSize)
Result appendSegment(const Segment2D &rSeg, bool bShiftToHit=false)
Result getBulgeAt(OdUInt32 iIndex, double &dBulge) const
void setClosed(bool bClosed=true)
Result getArcSegAt(OdUInt32 iIndex, OdGeCircArc2d &geArc) const
FaceOrientation orientationAt(OdUInt32 iIndex) const
OdUInt32 numVerts() const
SegmentType segmentType(OdUInt32 iIndex) const
Result getSegmentAt(OdUInt32 iIndex, OdGePoint2d &ptStart, OdGePoint2d &ptEnd, double &dBulge) const
Contour2D(ContourImplClass eImplClass)
Result setHiddenAt(OdUInt32 iIndex, bool bHidden=true)
Result setVertexAt(OdUInt32 iIndex, const OdGePoint2d &ptPoint, double dBulge)
Result setRawFlagsAt(OdUInt32 iIndex, OdUInt32 iRawFlags)
Result appendVertices(const OdGePoint2dArray &vecSource)
bool isExplodedArcAt(OdUInt32 iIndex) const
bool areEqualParams(double dParam1, double dParam2, double dParamTol=1e-10) const
bool traverse(Contour2DTraversingReactor &reactor) const
Contour2D & reset(ContourImplClass eImplClass=ecicUnknown)
ContourImplClass implClass() const
Result setPointAt(OdUInt32 iIndex, const OdGePoint2d &ptPoint)
bool isSelfIntersecting(const OdGeTol &gTol=FMGeGbl::gTol, bool bExcludeTouch=false) const
Result addExtents(OdGeExtents2d &extExtents) const
Result getParamAtDist(double dDist, double &dParam) const
Result getPointAt(OdUInt32 iIndex, OdGePoint2d &ptPoint) const
IContour2D & impl()
DOM.
Definition: FMContour2D.h:822
Result explode(const DeviationParams &devDeviation=FMGeGbl::gDefDev, OdIntPtr uArcMetadata=0)
Result getVertexAt(OdUInt32 iIndex, OdGePoint2d *pPoint, double *pBulge=0, OdIntPtr *pMetadata=0, OdUInt32 *puRawFlags=0) const
Result getTangentAtDist(double dDist, OdGeVector2d &vTangent) const
Result getStartPoint(OdGePoint2d &ptPoint) const
Result getTangent(double dParam, OdGeVector2d &vTangent) const
Result setExplodedArcAt(OdUInt32 iIndex, bool bExplodedArc=true)
Result getOffsetProfile(double dOffset, Profile2D &rResult, FilletType eFilletType=eftExtend, const OdGeTol &gTol=FMGeGbl::gTol) const
Result getSegmentAt(OdUInt32 iIndex, Segment2D &rSegment) const
Result setOrientationAt(OdUInt32 iIndex, FaceOrientation eOrientation)
Result getNormalizedParam(double &dParam) const
void makeCCW(bool bCCW=true)
double nearestParam(const OdGePoint2d &ptTest, OdGePoint2d *ptNearest=0) const
Result addVertexAt(OdUInt32 iIndex, const OdGePoint2d &ptStart, double dBulge=0.0, OdIntPtr uMetadata=0, OdUInt32 uRawFlags=0)
Result removeVertexAt(OdUInt32 iIndex)
Result appendVertex(const OdGePoint2d &ptStart, const OdGePoint2d &ptMid, OdIntPtr uMetadata=0, OdUInt32 uRawFlags=0)
bool isValidRegion(const OdGeTol &gTol=FMGeGbl::gTol) const
Contour2D & cloneFrom(const IContour2D &rSrcCont)
Result getEndPoint(OdGePoint2d &ptPoint) const
OdUInt32 numSegments() const
void mergeSegments(int iMergeFlags=0, const OdGeTol &gTol=FMGeGbl::gTol)
bool contains(const OdGePoint2d &ptPoint, bool *pOnBorder=0, const OdGeTol &gTol=FMGeGbl::gTol) const
static FMGEOMETRY_API_STATIC const Contour2D kNull
Definition: FMContour2D.h:832
bool areEqualDists(double dDist1, double dDist2, double dTol=1e-6) const
OdUInt32 createVertexAt(double dParam, const OdGeTol &gTol=FMGeGbl::gTol)
Result getPoint(double dParam, OdGePoint2d &ptPoint) const
Result getDistAtParam(double dParam, double &dDist) const
void setThreatAsSmoothCurveAt(OdUInt32 iIndex, bool bSmooth)
bool isEndsEqual(const OdGeTol &gTol=FMGeGbl::gTol) const
Result getInternalAngleAt(OdUInt32 iIndex, double &dAngle) const
double signedArea() const
Result getNormalizedDist(double &dDist) const
Result getPointAtDist(double dDist, OdGePoint2d &ptPoint) const
Result appendVertex(const OdGePoint2d &ptStart, double dBulge=0.0, OdIntPtr uMetadata=0, OdUInt32 uRawFlags=0)
Contour2D & operator=(const Contour2D &rSrcCont)
Result getSubContour(double dStartParam, double dEndParam, Contour2D &rSubContour, const OdGeTol &gTol=FMGeGbl::gTol) const
Result setBulgeAt(OdUInt32 iIndex, double dBulge)
void getGeomExtens(OdGeExtents2d &extens)
virtual bool onArcEndPoint(int nSegment, const OdGePoint2d &pt)=0
virtual bool onArcStartPoint(int nSegment, const OdGePoint2d &pt, int nTotalPts)=0
virtual bool onCoincidentSeg(int nSegment)=0
virtual bool onArcSeg(int nSegment, DeviationParams **ppDev)=0
virtual bool onLineSeg(int nSegment)=0
virtual bool onArcPoint(int nSegment, const OdGePoint2d &pt)=0
Definition: GeTol.h:49
FMGEOMETRY_API void ExtendContour(Contour2D &rContour)
FMGEOMETRY_API void ExtendContourEnd(Contour2D &rContour)
FMGEOMETRY_API void ExtendContourStart(Contour2D &rContour)
FMGEOMETRY_API bool FindClosestIntToBaseEnd(const Contour2D &cBase, const Contour2D &cCutter, Intersection &intClosest)
FMGEOMETRY_API bool FindClosestIntToBaseStart(const Contour2D &cBase, const Contour2D &cCutter, Intersection &intClosest)
FMGEOMETRY_API bool IsIntersectionCloserToPt(const OdGePoint2d &ptBase, const Intersection &intCurrent, const Intersection &intToCheck)
FMGEOMETRY_API Intersection FindIntClosestToPt(const OdGePoint2d &ptBase, const std::vector< Intersection > &vecPoints)
static FMGEOMETRY_API_STATIC DeviationParams gDefDev
Definition: FMGeometry.h:148
static FMGEOMETRY_API_STATIC OdGeTol gTol
Definition: FMGeometry.h:156