Fade2.5D Documentation pages v2.14
Delaunay Features
freeFunctions.h
Go to the documentation of this file.
1 // Copyright (C) Geom Software e.U, Bernhard Kornberger, Graz/Austria
2 //
3 // This file is part of the Fade2D library. The student license is free
4 // of charge and covers personal non-commercial research. Licensees
5 // holding a commercial license may use this file in accordance with
6 // the Commercial License Agreement.
7 //
8 // This software is provided AS IS with NO WARRANTY OF ANY KIND,
9 // INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
10 // FOR A PARTICULAR PURPOSE.
11 //
12 // Please contact the author if any conditions of this licensing are
13 // not clear to you.
14 //
15 // Author: Bernhard Kornberger, bkorn (at) geom.at
16 // http://www.geom.at
17 
18 
20 #pragma once
21 #include "Point2.h"
22 #include "Segment2.h"
23 #include "Edge2.h"
24 #include <vector>
25 
26 
27 #if GEOM_PSEUDO3D==GEOM_TRUE
28  namespace GEOM_FADE25D {
29 #elif GEOM_PSEUDO3D==GEOM_FALSE
30  namespace GEOM_FADE2D {
31 #else
32  #error GEOM_PSEUDO3D is not defined
33 #endif
34 
35 class Mesh3; // FWD
36 class Zone2; // FWD
37 
47 CLASS_DECLSPEC
48 void simplifyPolygon(const std::vector<Point2>& vIn,double errBound,std::vector<Point2>& vOut);
49 
50 
51 
82 CLASS_DECLSPEC
84  double offset,
85  const std::vector<Point2>& vOrgPoints,
86  std::vector<Point2>& vOffsetPoints,
87  double maxCorrectionFactor=1.0
88  );
89 
96 CLASS_DECLSPEC
97 void untwistPolygon(std::vector<Segment2>& vPolygon,std::vector<std::vector<Segment2> >& vvPolygon);
98 
99 
116 CLASS_DECLSPEC
117 int setGlobalNumCPU(int numCPU);
118 
125 CLASS_DECLSPEC
127 
128 
129 // Expects _one_ edge-connected component. No problem if the component
130 // forms a ring around a void that touches only at one vertex. But keep
131 // in mind that two completely disjoint borders may exist. This is why
132 // we use sIgnorePairs.
152 CLASS_DECLSPEC
153 void getSortedBoundaryPolygons( std::vector<Triangle2*>& vConnectedComponent,
154  std::vector<Edge2>& vOutsidePolygon,
155  std::vector<std::vector<Edge2> >& vHolePolygons
156  );
157 
158 
176 CLASS_DECLSPEC
177 void pointsToPolyline(std::vector<Point2>& vInPoints,bool bClose,std::vector<Segment2>& vOutSegments);
178 
179 
180 
189 CLASS_DECLSPEC
190 bool isSimplePolygon(std::vector<Segment2>& vSegments);
191 
192 #if GEOM_PSEUDO3D==GEOM_TRUE
204 CLASS_DECLSPEC
206  const Point2& p1,
207  const Point2& p2,
208  bool& bOK);
209 #endif
210 
211 
212 
213 
214 #if GEOM_PSEUDO3D==GEOM_TRUE
224 CLASS_DECLSPEC
225 double getArea25D(const Point2* p0,const Point2* p1,const Point2* p2);
226 #endif
227 
228 
242 CLASS_DECLSPEC
243 double getArea2D(const Point2* p0,const Point2* p1,const Point2* p2);
244 
245 
251 CLASS_DECLSPEC
252 void getDirectedEdges(const std::vector<Triangle2*>& vT,std::vector<Edge2>& vDirectedEdgesOut);
253 
258 CLASS_DECLSPEC
259 void getUndirectedEdges(const std::vector<Triangle2*>& vT,std::vector<Edge2>& vUndirectedEdgesOut);
260 
271 CLASS_DECLSPEC
272 void getConnectedComponents( const std::vector<Triangle2*>& vT,
273  std::vector<std::vector<Triangle2*> >& vvT
274  );
275 
276 
300 CLASS_DECLSPEC
301 bool fillHole( const std::vector<std::pair<Segment2,Vector2> >& vPolygonSegments,
302  bool bWithRefine,
303  bool bVerbose,
304  std::vector<Point2>& vCornersOut
305  );
306 
307 
308 
309 
310 #if GEOM_PSEUDO3D==GEOM_TRUE
329 CLASS_DECLSPEC
330 bool fillHole( const std::vector<Point2>& vMeshCorners,
331  const std::vector<Segment2>& vPolygonSegments,
332  bool bWithRefine,
333  bool bVerbose,
334  std::vector<Point2>& vCornersOut
335  );
336 
354 CLASS_DECLSPEC
355 bool fillHole( Mesh3* pMesh,
356  const std::vector<Edge2>& vPolygonEdges,
357  bool bWithRefine,
358  bool bVerbose,
359  std::vector<Point2>& vCornersOut
360  );
361 #endif
362 
363 
393 CLASS_DECLSPEC
395  const std::vector<Edge2>& vEdgesIn,
396  std::vector<std::vector<Edge2> >& vvPolygonsOut,
397  std::vector<Edge2>& vRemainingOut
398  );
399 
408 CLASS_DECLSPEC
409 void getBorders(const std::vector<Triangle2*>& vT,std::vector<Segment2>& vBorderSegmentsOut);
415 CLASS_DECLSPEC
416 bool sortRing(std::vector<Segment2>& vRing);
417 
418 //CLASS_DECLSPEC
419 //bool temporaryDebug(std::vector<Segment2>& vRing);
420 
427 CLASS_DECLSPEC
428 bool sortRingCCW(std::vector<Segment2>& vRing);
429 
430 
442 CLASS_DECLSPEC
443 Orientation2 getOrientation2(const Point2* p0,const Point2* p1,const Point2* p2);
451 CLASS_DECLSPEC
452 Orientation2 getOrientation2_mt(const Point2* p0,const Point2* p1,const Point2* p2);
453 
455 CLASS_DECLSPEC
456 const char* getString(const Orientation2 ori);
457 
467 CLASS_DECLSPEC
468 const char* getFade2DVersion();
471 CLASS_DECLSPEC
475 CLASS_DECLSPEC
479 CLASS_DECLSPEC
483 CLASS_DECLSPEC
484 bool isRelease();
485 
487 CLASS_DECLSPEC
488 void setLic(
489  const char* l1,
490  const char* l2,
491  const char* dt,
492  const char* s1,
493  const char* s2_
494  );
496 class Lic;
498 Lic* getLic();
499 
515 // READ AND WRITE, ASCII
517 
535 CLASS_DECLSPEC
536 bool writePointsASCII(const char* filename,const std::vector<Point2*>& vPointsIn);
537 
544 CLASS_DECLSPEC
545 bool writePointsASCII(const char* filename,const std::vector<Point2>& vPointsIn);
546 
547 
548 
549 
550 
560 CLASS_DECLSPEC
561 bool readXY(const char* filename,std::vector<Point2>& vPointsOut);
562 
563 #if GEOM_PSEUDO3D==GEOM_TRUE
564 // ONLY 2.5D
570 CLASS_DECLSPEC
571 bool readXYZ(const char* filename,std::vector<Point2>& vPointsOut);
572 #endif
573 
574 
575 
577 // READ AND WRITE, PLY
579 #ifndef SKIPTHREADS
591 CLASS_DECLSPEC
592 bool readPointsPLY(const char* filename,bool bUniquePoints,std::vector<Point2>& vPoints,std::vector<VtxColor>* pVertexColors=NULL);
593 
594 
607 CLASS_DECLSPEC
608 bool readPointsPLY(std::istream& is,bool bUniquePoints,std::vector<Point2>& vPoints,std::vector<VtxColor>* pVertexColors=NULL);
609 
610 
619 CLASS_DECLSPEC
620 bool writePointsPLY(std::ostream& os,std::vector<Point2*>& vPoints,bool bASCII);
621 
622 
631 CLASS_DECLSPEC
632 bool writePointsPLY(const char* filename,std::vector<Point2*>& vPoints,bool bASCII);
633 
634 #endif
635 
636 
637 
639 // READ AND WRITE, BINARY
641 
642 
643 
661 CLASS_DECLSPEC
662 bool writePointsBIN(const char* filename,std::vector<Point2>& vPoints);
663 
681 CLASS_DECLSPEC
682 bool writePointsBIN(const char* filename,std::vector<Point2*>& vPoints);
683 
697 CLASS_DECLSPEC
698 bool readPointsBIN(const char* filename, std::vector<Point2>& vPointsIn,bool bWithHeader=true);
699 
737 CLASS_DECLSPEC
738 bool writeSegmentsBIN(const char* filename,std::vector<Segment2>& vSegmentsIn);
739 
746 CLASS_DECLSPEC
747 bool readSegmentsBIN(const char* filename,std::vector<Segment2>& vSegmentsOut);
748 
749 
750 
751 
752 
753 
755 } // NAMESPACE
Point.
Definition: Point2.h:53
Vector.
Definition: Vector2.h:42
void getSortedBoundaryPolygons(std::vector< Triangle2 * > &vConnectedComponent, std::vector< Edge2 > &vOutsidePolygon, std::vector< std::vector< Edge2 > > &vHolePolygons)
Get sorted boundary polygons.
void untwistPolygon(std::vector< Segment2 > &vPolygon, std::vector< std::vector< Segment2 > > &vvPolygon)
Repair a selfintersecting polygon.
int setGlobalNumCPU(int numCPU)
Set the global number of threads to be used.
void offsetPolygonPoints(double offset, const std::vector< Point2 > &vOrgPoints, std::vector< Point2 > &vOffsetPoints, double maxCorrectionFactor=1.0)
Create an offet polygon.
void simplifyPolygon(const std::vector< Point2 > &vIn, double errBound, std::vector< Point2 > &vOut)
Simplify a polygon.
int getGlobalNumCPU()
Get the global number of threads to be used.
int getMajorVersionNumber()
Get the major version number.
const char * getFade2DVersion()
Get the Fade2D version string.
int getMinorVersionNumber()
Get the minor version number.
int getRevisionNumber()
Get the revision version number.
bool isRelease()
Check if a RELEASE or a DEBUG version is used.
bool readPointsBIN(const char *filename, std::vector< Point2 > &vPointsIn, bool bWithHeader=true)
Read points from a binary file.
bool readXY(const char *filename, std::vector< Point2 > &vPointsOut)
Read (x y) points.
bool readXYZ(const char *filename, std::vector< Point2 > &vPointsOut)
Read (x y z) points.
bool readSegmentsBIN(const char *filename, std::vector< Segment2 > &vSegmentsOut)
Read segments from a binary file.
bool readPointsPLY(std::istream &is, bool bUniquePoints, std::vector< Point2 > &vPoints, std::vector< VtxColor > *pVertexColors=NULL)
Read points from a *.PLY file.
bool writeSegmentsBIN(const char *filename, std::vector< Segment2 > &vSegmentsIn)
Write segments to a binary file.
bool writePointsPLY(const char *filename, std::vector< Point2 * > &vPoints, bool bASCII)
Write points to a *.PLY file.
bool writePointsBIN(const char *filename, std::vector< Point2 * > &vPoints)
Write points to a binary file.
bool writePointsASCII(const char *filename, const std::vector< Point2 > &vPointsIn)
Write points to an ASCII file.
bool isSimplePolygon(std::vector< Segment2 > &vSegments)
isSimplePolygon
void pointsToPolyline(std::vector< Point2 > &vInPoints, bool bClose, std::vector< Segment2 > &vOutSegments)
Points-to-Polyline.
Orientation2 getOrientation2(const Point2 *p0, const Point2 *p1, const Point2 *p2)
Get the orientation of three points.
void getConnectedComponents(const std::vector< Triangle2 * > &vT, std::vector< std::vector< Triangle2 * > > &vvT)
Get connected components.
void getUndirectedEdges(const std::vector< Triangle2 * > &vT, std::vector< Edge2 > &vUndirectedEdgesOut)
Get undirected edges.
double getArea25D(const Point2 *p0, const Point2 *p1, const Point2 *p2)
Get 2.5D area of a triangle.
bool sortRing(std::vector< Segment2 > &vRing)
Sort a vector of Segments.
double getArea2D(const Point2 *p0, const Point2 *p1, const Point2 *p2)
Get 2D area of a triangle.
void getDirectedEdges(const std::vector< Triangle2 * > &vT, std::vector< Edge2 > &vDirectedEdgesOut)
Get directed edges The directed edges of vT are returned in vDirectedEdgesOut. Directed means that ea...
void edgesToPolygons(const std::vector< Edge2 > &vEdgesIn, std::vector< std::vector< Edge2 > > &vvPolygonsOut, std::vector< Edge2 > &vRemainingOut)
Create polygons from a set of edges.
Orientation2 getOrientation2_mt(const Point2 *p0, const Point2 *p1, const Point2 *p2)
Get Orientation2 (MT)
Vector2 getNormalVector(const Point2 &p0, const Point2 &p1, const Point2 &p2, bool &bOK)
Get normal vector.
bool fillHole(Mesh3 *pMesh, const std::vector< Edge2 > &vPolygonEdges, bool bWithRefine, bool bVerbose, std::vector< Point2 > &vCornersOut)
Fill a hole in a 3D mesh with triangles (deprecated)
bool sortRingCCW(std::vector< Segment2 > &vRing)
Sort a vector of Segments.
void getBorders(const std::vector< Triangle2 * > &vT, std::vector< Segment2 > &vBorderSegmentsOut)
Get Borders.