Represents a defined area within a triangulation. More...
#include <Zone2.h>
Public Member Functions | |
Zone2 * | convertToBoundedZone () |
Convert a zone to a bounded zone. More... | |
Zone2 * | createOffsetZone (Fade_2D *pFade, double offset, double mergeAngleDeg=10, double angleStep=20.0) const |
Creates an offset zone. More... | |
void | exportZone (FadeExport &fadeExport, bool bWithCustomIndices) const |
Export triangles from a zone. More... | |
double | getArea2D () const |
Get 2D Area. More... | |
void | getBorderEdges (std::vector< Edge2 > &vBorderEdgesOut) const |
Get border edges. More... | |
void | getBoundarySegments (std::vector< Segment2 > &vSegments) const |
Get the boundaries as segments. More... | |
Bbox2 | getBoundingBox () const |
Compute the bounding box. | |
void | getComponentPolygons (std::vector< CompPolygon > &vCompPolygons) const |
Get connected components. More... | |
ConstraintGraph2 * | getConstraintGraph () const |
Get the associated constraint. More... | |
void | getConstraintGraphs (std::vector< ConstraintGraph2 * > &vConstraintGraphs_) const |
Get the associated constraint graphs. | |
double | getMedianEdgeLength2D () |
Get the median 2D edge length. More... | |
ConstraintSegment2 * | getNearbyBoundaryConstraint (Point2 &p, double tolerance) |
Locates the nearest boundary ConstraintSegment2 of the Zone2. More... | |
size_t | getNumberOfTriangles () const |
Get the number of triangles. More... | |
void | getOffsetBoundary (double offset, std::vector< Segment2 > &vOffsetBoundary, double mergeAngleDeg=10.0, double angleStepDeg=20.0) const |
Get the offset boundary of a shape. More... | |
void | getTriangles (std::vector< Triangle2 * > &vTriangles) const |
Get the triangles of the zone. More... | |
void | getVertices (std::vector< Point2 * > &vVertices_) const |
Get the vertices of the zone. | |
ZoneLocation | getZoneLocation () const |
Get the zone location. More... | |
bool | hasOn (const Point2 &p) |
Checks if a point lies on the zone. More... | |
bool | hasOnBoundary (const Point2 &p) |
Checks if a point lies on the boundary of the zone. More... | |
Triangle2 * | locate (const Point2 &p) |
Locates the triangle containing the given point within the zone. More... | |
Zone2 * | morphClose (Fade_2D *pFade, double offset, double mergeAngleDeg=10.0, double angleStep=20.0) const |
Morphological closing to bridge small gaps in the Zone2. More... | |
Zone2 * | morphOpen (Fade_2D *pFade, double offset, double mergeAngleDeg=10.0, double angleStep=20.0) const |
Morphological opening to remove small details. More... | |
size_t | numberOfConstraintGraphs () const |
Get the number of ConstraintGraph2 objects. More... | |
bool | save (const char *filename) |
Save the zone. More... | |
bool | save (std::ostream &stream) |
Save the zone. More... | |
bool | shiftToZone (const Point2 &q, double tolerance, Point2 &result) |
Finds a point close to the query that lies inside the zone. More... | |
void | show (const char *filename, bool bShowFull, bool bWithConstraints) const |
Postscript- and PDF-visualization. More... | |
void | show (Visualizer2 *pVisualizer, bool bShowFull, bool bWithConstraints) const |
Postscript- and PDF-visualization. More... | |
void | showVtk (const char *filename, VtkColor zoneColor, VtkColor nonZoneColor=VTK_TRANSPARENT, VtkColor constraintColor=VTK_TRANSPARENT) const |
VTK visualization. More... | |
void | showVtk (VtkWriter *pVtk, VtkColor zoneColor, VtkColor nonZoneColor=VTK_TRANSPARENT, VtkColor constraintColor=VTK_TRANSPARENT) const |
VTK visualization. More... | |
void | statistics (const char *s) const |
Prints statistics. More... | |
void | subscribe (MsgType msgType, MsgBase *pMsg) |
Registers a message receiver. More... | |
void | unifyGrid (double tolerance) |
Unify Grid. More... | |
void | unsubscribe (MsgType msgType, MsgBase *pMsg) |
Unregisters a message receiver. More... | |
void | writeObj (const char *filename) const |
Write the Zone2 to an .obj file. More... | |
Protected Member Functions | |
Zone2 & | operator= (const Zone2 &) |
Friends | |
CLASS_DECLSPEC friend Zone2 * | peelOffIf (Zone2 *pZone, bool bAvoidSplit, PeelPredicateTS *pPredicate) |
Peel off undesired border triangles. More... | |
CLASS_DECLSPEC friend Zone2 * | peelOffIf (Zone2 *pZone, UserPredicateT *pPredicate, bool bVerbose) |
Peel off undesired border triangles (deprecated) More... | |
CLASS_DECLSPEC friend Zone2 * | zoneDifference (Zone2 *pZone0, Zone2 *pZone1) |
Computes the difference between two Zone2 objects. More... | |
CLASS_DECLSPEC friend Zone2 * | zoneIntersection (Zone2 *pZone0, Zone2 *pZone1) |
Computes the intersection of two Zone2 objects. More... | |
CLASS_DECLSPEC friend Zone2 * | zoneSymmetricDifference (Zone2 *pZone0, Zone2 *pZone1) |
Computes the symmetric difference between two Zone2 objects. More... | |
CLASS_DECLSPEC friend Zone2 * | zoneUnion (Zone2 *pZone0, Zone2 *pZone1) |
Computes the union of two Zone2 objects. More... | |
A Zone2
object represents a defined area within a triangulation.
Zone2
objects. Zone2* GEOM_FADE2D::Zone2::convertToBoundedZone | ( | ) |
This method creates a bounded zone from a possibly unbounded one.
Algorithms like refine()
and refineAdvanced()
require a Zone2
object as input that is bounded by constraint edges. This is always the case for zones with zoneLocation
ZL_INSIDE
, but other types of zones may be unbounded.
Zone2
object with zoneLocation
ZL_RESULT_BOUNDED
or a pointer to the present Zone2
if this->getZoneLocation()
returns ZL_INSIDE
. Zone2* GEOM_FADE2D::Zone2::createOffsetZone | ( | Fade_2D * | pFade, |
double | offset, | ||
double | mergeAngleDeg = 10 , |
||
double | angleStep = 20.0 |
||
) | const |
Creates a positive or negative offset zone based on the current Zone2 and stores the result in a new Fade_2D
object.
[in] | pFade | An empty Fade_2D object where the result zone will be created. |
[in] | offset | The positive or negative offset distance. |
[in] | mergeAngleDeg | is used as an angle threshold (in degrees) to merge small circular arcs in the offset shape into a single point. Default: 10.0, valid range: (>0,...,135) |
[in] | angleStep | Specifies the angle interval (in degrees) at which circular arcs in the offset shape are sampled using line segments. Default: 20.0, valid range: (>0,...,135) |
Zone2
object, created within pFade
or NULL
if the result is empty, which may be the case if a large negative offset value is used. Be sure to check this case before proceeding. void GEOM_FADE2D::Zone2::exportZone | ( | FadeExport & | fadeExport, |
bool | bWithCustomIndices | ||
) | const |
Exports the Zone2 to a FadeExport struct.
fadeExport | is a simple struct that will be filled with data |
bWithCustomIndices | determines whether the custom indices of the points are also stored |
double GEOM_FADE2D::Zone2::getArea2D | ( | ) | const |
void GEOM_FADE2D::Zone2::getBorderEdges | ( | std::vector< Edge2 > & | vBorderEdgesOut | ) | const |
void GEOM_FADE2D::Zone2::getBoundarySegments | ( | std::vector< Segment2 > & | vSegments | ) | const |
void GEOM_FADE2D::Zone2::getComponentPolygons | ( | std::vector< CompPolygon > & | vCompPolygons | ) | const |
This method finds connected components of the Zone2. For each connected component, it returns a CompPolygon
struct consisting of Triangle2
pointers of that component, the outer boundary polygon, and any hole polygons within the component, represented as Edge2
vectors.
[out] | vCompPolygons | A vector that will hold the CompPolygon structs for each connected component. |
ConstraintGraph2* GEOM_FADE2D::Zone2::getConstraintGraph | ( | ) | const |
Retrieves the associated ConstraintGraph2, if any.
ConstraintGraph2
object defining the Zone2, or NULL
if no ConstraintGraph2 is associated. double GEOM_FADE2D::Zone2::getMedianEdgeLength2D | ( | ) |
Computes the median edge length of all edges in the current zone in 2D.
ConstraintSegment2* GEOM_FADE2D::Zone2::getNearbyBoundaryConstraint | ( | Point2 & | p, |
double | tolerance | ||
) |
This method locates the nearest ConstraintSegment2
on the boundary of the current Zone2 within the specified distance, but only if the point p
has an orthogonal projection onto this ConstraintSegment2
.
p | The point from which the search is initiated. |
tolerance | The maximum allowed 2D distance between the point p and the ConstraintSegment2 . |
ConstraintSegment2
within the tolerance distance, where p
has an orthogonal projection, or NULL if no such ConstraintSegment2
is found.ZL_INSIDE
, ZL_BOUNDED
, or ZL_GLOBAL
, constraint edges are inserted around the zone. size_t GEOM_FADE2D::Zone2::getNumberOfTriangles | ( | ) | const |
This method computes and returns the number of triangles in the Zone2.
void GEOM_FADE2D::Zone2::getOffsetBoundary | ( | double | offset, |
std::vector< Segment2 > & | vOffsetBoundary, | ||
double | mergeAngleDeg = 10.0 , |
||
double | angleStepDeg = 20.0 |
||
) | const |
This function computes an offset boundary of a Zone2. The result is returned as a vector of counterclockwise-oriented Segment2
objects.
[in] | offset | The positive or negative offset distance. |
[out] | vOffsetBoundary | A vector that will contain the output segments, in arbitrary order, oriented counterclockwise around the resulting shape. |
[in] | mergeAngleDeg | The angle threshold (in degrees) used to merge circular arcs in the offset boundary. Arcs with an angle less than this value are collapsed to a single point. Default: 10.0, valid range: greater than 0 and up to 135. |
[in] | angleStepDeg | Specifies the angle interval (in degrees) at which circular arcs are sampled using line segments. Default: 20.0, valid range: greater than 0 and up to 135. |
void GEOM_FADE2D::Zone2::getTriangles | ( | std::vector< Triangle2 * > & | vTriangles | ) | const |
ZoneLocation GEOM_FADE2D::Zone2::getZoneLocation | ( | ) | const |
This method is used to retrieve the ZoneLocation value of the present Zone2.
bool GEOM_FADE2D::Zone2::hasOn | ( | const Point2 & | p | ) |
This method checks if the query point p
lies on the Zone2 or its boundary.
p | The point to check. |
true
if the point is on the Zone2 or its boundary, false
otherwise.The first call to this method initializes a search structure. If boundary edges of the Zone2 are not constraint edges yet, constraint edges are created.
bool GEOM_FADE2D::Zone2::hasOnBoundary | ( | const Point2 & | p | ) |
This method checks if the query point p
lies exactly on the boundary of the present Zone2.
p | The point to check. |
true
if the point is on the zone's boundary, false
otherwise.The first call to this method initializes a search structure. If boundary edges of the Zone2 are not constraint edges yet, constraint edges are created.
Zone2* GEOM_FADE2D::Zone2::morphClose | ( | Fade_2D * | pFade, |
double | offset, | ||
double | mergeAngleDeg = 10.0 , |
||
double | angleStep = 20.0 |
||
) | const |
Morphological closing bridges small gaps between shapes by applying dilation (positive offset) followed by erosion (negative offset) using a disk-shaped structuring element whose radius can be chosen. The result is stored in a new Zone2 object, created within the provided Fade_2D
object.
pFade | An empty Fade_2D object that will hold the result of the operation (the closed zone). |
offset | The offset distance. It defines the radius of the disk-shaped structuring element. This value must be positive. |
mergeAngleDeg | An angle threshold (in degrees). Circular arcs in the result which have an angle smaller than this value are collapsed into a single point. Recommended value: 91 degrees, to avoid most arcs. |
angleStep | The angle interval (in degrees) at which circular arcs in the offset boundary, if any, are sampled using line segments. Default value: 20.0. Valid range: greater than 0 and up to 135. |
Zone2
object, created in pFade
, representing the result of the morphological closing.Zone2* GEOM_FADE2D::Zone2::morphOpen | ( | Fade_2D * | pFade, |
double | offset, | ||
double | mergeAngleDeg = 10.0 , |
||
double | angleStep = 20.0 |
||
) | const |
Morphological opening removes small details from a shape by applying erosion (negative offset) followed by dilation (positive offset) using a disk-shaped structuring element whose radius can be chosen. The result is stored in a new Zone2 object, which is created in the provided Fade_2D
object.
pFade | An empty Fade_2D object in which the result will be created as a Zone2. |
offset | The offset distance, which defines the radius of the disk-shaped structuring element. This value must be positive. |
mergeAngleDeg | An angle threshold (in degrees). Circular arcs in the result which have an angle smaller than this value are collapsed into a single point. Recommended value: 91 degrees, to avoid most arcs. |
angleStep | The angle interval (in degrees) at which circular arcs in the offset boundary, if any, are sampled using line segments. Default value: 20.0. Valid range: greater than 0 and up to 135. |
Zone2
object, created in pFade
, representing the result of the morphological opening operation.NULL
. Be sure to check for this condition before proceeding. size_t GEOM_FADE2D::Zone2::numberOfConstraintGraphs | ( | ) | const |
Retrieves the number of ConstraintGraph2 objects.
bool GEOM_FADE2D::Zone2::save | ( | const char * | filename | ) |
This command saves the present Zone2 to a binary file. Any constraint edges and custom indices in the domain are retained.
[in] | filename | is the output filename |
bool GEOM_FADE2D::Zone2::save | ( | std::ostream & | stream | ) |
This command saves the present Zone2 to an ostream. Any constraint edges and custom indices in the domain are retained.
stream | is the output stream |
This method finds a point close to the query point q
that lies inside the Zone2 or on its boundary.
[in] | q | A point outside the Zone2. |
[in] | tolerance | The maximum allowed 2D distance to find a point on the Zone2. |
[out] | result | A reference to store the point found within the Zone2, close to q . |
true
if a point within the zone is successfully found and returned as result
; false
otherwise.The first call to this method initializes a search structure. If boundary edges of the Zone2 are not constraint edges yet, constraint edges are created.
void GEOM_FADE2D::Zone2::show | ( | const char * | filename, |
bool | bShowFull, | ||
bool | bWithConstraints | ||
) | const |
This method visualizes and saves the Zone2 as a PDF or Postscript file.
filename | The name of the output file. Use .ps or .pdf as the file extension. |
bShowFull | Specifies whether only the Zone2 or the full triangulation should be drawn. |
bWithConstraints | Specifies whether constraint edges should be drawn. |
void GEOM_FADE2D::Zone2::show | ( | Visualizer2 * | pVisualizer, |
bool | bShowFull, | ||
bool | bWithConstraints | ||
) | const |
This method visualizes and saves the Zone2 as a PDF or Postscript file.
pVisualizer | A pointer to an existing Visualizer2 object. |
bShowFull | Specifies whether only the Zone2 or the full triangulation should be drawn. |
bWithConstraints | Specifies whether constraint edges should be drawn. |
void GEOM_FADE2D::Zone2::showVtk | ( | const char * | filename, |
VtkColor | zoneColor, | ||
VtkColor | nonZoneColor = VTK_TRANSPARENT , |
||
VtkColor | constraintColor = VTK_TRANSPARENT |
||
) | const |
This method visualizes and saves the Zone2 as a VTK file, which can be viewed in tools like Paraview.
filename | The name of the output file. |
zoneColor | The color for the zone's triangles. |
nonZoneColor | The color for the non-zone triangles. Use VTK_TRANSPARENT to prevent them from being drawn. |
constraintColor | The color of the constraint edges. Use VTK_TRANSPARENT to prevent them from being drawn. |
void GEOM_FADE2D::Zone2::showVtk | ( | VtkWriter * | pVtk, |
VtkColor | zoneColor, | ||
VtkColor | nonZoneColor = VTK_TRANSPARENT , |
||
VtkColor | constraintColor = VTK_TRANSPARENT |
||
) | const |
This method visualizes and saves the Zone2 as a VTK file, which can be viewed in tools like Paraview.
pVtk | A VtkWriter object that may already contain other geometric objects |
zoneColor | The color for the zone's triangles. |
nonZoneColor | The color for the non-zone triangles. Use VTK_TRANSPARENT to prevent them from being drawn. |
constraintColor | The color of the constraint edges. Use VTK_TRANSPARENT to prevent them from being drawn. |
void GEOM_FADE2D::Zone2::statistics | ( | const char * | s | ) | const |
Prints statistics.
This method registers a subscriber to receive messages of a specified type.
msgType | The type of message the subscriber will receive, e.g., MSG_PROGRESS or MSG_WARNING . |
pMsg | A pointer to a custom class derived from MsgBase that will handle the messages. |
void GEOM_FADE2D::Zone2::unifyGrid | ( | double | tolerance | ) |
A Delaunay triangulation is not unique when two or more triangles share a common circumcircle. For example, the four corners of a rectangle can be triangulated in two ways. This method unifies such cases by ensuring diagonals always go from the lower left to the upper right corner (or horizontally) for consistency and visual appearance.
tolerance | Defines the maximum allowed error in diagonal lengths due to noise or rounding errors. A value of 0 restricts changes to exact cases. The error is computed as: error = abs(diagonalA - diagonalB) / max(diagonalA, diagonalB) |
This method removes a subscriber from receiving messages of a specified type.
msgType | The type of message that the subscriber will no longer receive. |
pMsg | A pointer to a custom class derived from MsgBase representing the subscriber to be removed. |
void GEOM_FADE2D::Zone2::writeObj | ( | const char * | filename | ) | const |
This method writes the current Zone2 data to an .obj file, which can be used for visualization and further processing in tools like Meshlab.
filename | The output filename. |
|
friend |
Triangulations often contain narrow, nearly vertical triangles at their borders. This function returns a Zone2
that includes all triangles from pZone
, except the undesired ones. If no triangles remain, the method returns NULL
. A user-defined predicate distinguishes between desired and undesired triangles.
pZone | The input zone. |
bAvoidSplit | If true , the algorithm removes a triangle only if it does not split the zone into independent components. |
pPredicate | A user-defined predicate to decide whether a triangle should be removed. |
pZone
, or NULL
if no triangles remain.
|
friend |
This function returns a pointer to a new Zone2 object representing the difference between pZone0
and pZone1
(i.e., pZone0
minus pZone1
). The input zones must belong to the same Fade_2D object.
NULL
. Be sure to check this case before proceeding. This function returns a pointer to a new Zone2 object representing the intersection of the two input zones. The intersection is the area covered by both input zones. The input zones must belong to the same Fade_2D object.
NULL
. Be sure to check for this case before proceeding. This function returns a pointer to a new Zone2 object representing the symmetric difference between the two input zones. The symmetric difference is the area covered by either of the input zones, but not by both. The input zones must belong to the same Fade_2D object.
NULL
. Be sure to check for this case before proceeding. This function returns a pointer to a new Zone2 object representing the union of the two input zones. The union is the area covered by either of the input zones. Both input zones must belong to the same Fade_2D object.