AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
Attributes of Topological Structures​

Orientation

There are 4 types of OrientationType: Forward, Reversed, Internal, and External, with Forward and Reversed being the most commonly used. Any level of TopoShape can set its Orientation using SetOrientation() or retrieve its Orientation using Orientation(). If you want to get a TopoShape that only differs in Orientation from the current TopoShape, you can use Orientated().Orientation is independent of geometry and Location, meaning that changing one will not affect any other members.

Vertex

For an Edge, the Orientation of the starting Vertex is Forward, and the Orientation of the ending Vertex is Reversed. For example, a line segment Edge with two different Vertices will have one with Forward Orientation and the other with Reversed Orientation. Similarly, an Edge formed by a circle with two identical Vertices will still have one Vertex with Forward Orientation and the other with Reversed Orientation.

auto c = std::make_shared<AMCAX::Geom3Circle>(AMCAX::Frame3(), 1.0);
//Make a vertex
//Set the orientation of v2 to Reversed
v2.SetOrientation(AMCAX::OrientationType::Reversed);
//Make a edge
// Add different vertices
builder.Add(edge, v1);
builder.Add(edge, v2);
std::cout << AMCAX::TopoTool::IsClosed(edge) << std::endl;//0
//Make a edge2
// Add same vertices
builder.Add(edge2, v1);
builder.Add(edge2, v1.Oriented(AMCAX::OrientationType::Reversed));
std::cout << AMCAX::TopoTool::IsClosed(edge2) << std::endl;//1
Class of making a vertex.
Definition MakeVertex.hpp:18
static constexpr double Confusion() noexcept
Get the confusion tolerance.
Definition Precision.hpp:122
Class of a tool for building B-Rep structure.
Definition TopoBuilder.hpp:39
AMCAX_API void MakeEdge(TopoEdge &e) const
Make an empty edge.
AMCAX_API void Add(TopoShape &s, const TopoShape &c) const
Add a sub-shape to a shape.
Class of edge.
Definition TopoEdge.hpp:12
AMCAX_API TopoShape Oriented(OrientationType orient) const noexcept
Get the shape with given orientation.
AMCAX_API void SetOrientation(OrientationType orient) noexcept
Set the orientation of shape.
static AMCAX_API bool IsClosed(const TopoShape &s)
Is the shape closed.
Class of vertex.
Definition TopoVertex.hpp:12
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459
FrameT< double, 3 > Frame3
3D frame
Definition FrameT.hpp:887

Note: In this example, because the Edge formed by a circle has two identical Vertices, only one vertex needs to be constructed. In this case, AMCAX::TopoTool::IsClosed(edge) will return true. If two vertices are constructed, AMCAX::TopoTool::IsClosed(edge) will return false.

Edge

The Forward direction of an Edge is the direction of curve3d. If there is no curve3d, it's the direction of the pcurve. The direction of a Reversed Edge is opposite to that of the curve.
For example, given three Edges formed using 3d curves on the xoy plane and a Geom3Plane constructed using the natural frame:

Since the direction of the Wire must be counterclockwise in the parameter domain, Reversed Edge0, Forward Edge2, and Forward Edge1 should form the Wire.

If a clockwise Wire is used, i.e., Forward Edge0, Reversed Edge1, and Reversed Edge2, the Face will define the region outside the Wire. Below are the counterclockwise and clockwise Wires:

If the Geom3Plane is constructed using Frame3(O, -OZ, OX), the Wire direction should be clockwise, i.e., Forward Edge0, Reversed Edge1, and Reversed Edge2, ensuring that the Face is correctly defined as the area enclosed by the Wire.

Wire

Reversing a Wire is equivalent to reversing the Orientation of each Edge in the Forward Wire.

//Make a box
AMCAX::MakeBox box(AMCAX::Point3(-5.0, -5.0, 0.0), AMCAX::Point3(5.0, 5.0, 3.0));
//Get the wire from box
AMCAX::TopoExplorerTool::MapShapes(box, AMCAX::ShapeType::Wire, wireSet);
//Get the edge from wire1
AMCAX::TopoExplorerTool::MapShapes(wire1, AMCAX::ShapeType::Edge, edgeSet);
std::cout << int(edge1.Orientation()) << std::endl;//0
//Reverse the orientation of the wire1
//Get the edge from rewire
AMCAX::TopoExplorerTool::MapShapes(rewire, AMCAX::ShapeType::Edge, edgeSet2);
AMCAX::TopoEdge reedge = AMCAX::TopoCast::Edge(edgeSet2[0]);
std::cout << int(reedge.Orientation()) << std::endl;//1
Class of making a box.
Definition MakeBox.hpp:20
static AMCAX_API const TopoEdge & Edge(const TopoShape &s)
Cast shape to edge.
static AMCAX_API const TopoWire & Wire(const TopoShape &s)
Cast shape to wire.
static AMCAX_API void MapShapes(const TopoShape &s, ShapeType t, IndexSet< TopoShape > &shapeSet)
Construct a set of sub-shapes of given type.
AMCAX_API TopoShape Reversed() const noexcept
Get the shape with reversed orientation.
AMCAX_API OrientationType Orientation() const noexcept
Get the orientation of shape.
Class of wire.
Definition TopoWire.hpp:12

Face

Reversing a Face changes the direction of the region it encloses to the opposite of the surface normal. Reversing a Face is equivalent to reversing the Orientation of each Wire in the Forward Face.

//Make a box
AMCAX::TopoShape box = AMCAX::MakeBox(AMCAX::Point3(-5.0, -5.0, 0.0), AMCAX::Point3(5.0, 5.0, 3.0));
//Get the face from box
AMCAX::TopoExplorerTool::MapShapes(box, AMCAX::ShapeType::Face, faceSet);
std::cout << int(face1.Orientation()) << std::endl;//1
//Get the wire from face1
AMCAX::TopoExplorerTool::MapShapes(face1, AMCAX::ShapeType::Wire, wireSet);
std::cout << int(wire1.Orientation()) << std::endl;//1
//Reverse the orientation of the face1
std::cout << int(reface1.Orientation()) << std::endl;//0
//Get the wire from reface
AMCAX::TopoExplorerTool::MapShapes(reface1, AMCAX::ShapeType::Wire, rewireSet);
AMCAX::TopoWire rewire1 = AMCAX::TopoCast::Wire(rewireSet[0]);
std::cout << int(rewire1.Orientation()) << std::endl;//0
static AMCAX_API const TopoFace & Face(const TopoShape &s)
Cast shape to face.
Class of face.
Definition TopoFace.hpp:12
Base class of shape, containing an underlying shape with a location and an orientation.
Definition TopoShape.hpp:15

The method to retrieve the normal of the surface where the Face lies is as follows:

//Get the surface of face1
std::shared_ptr< AMCAX::Geom3Surface > surface = AMCAX::TopoTool::Surface(face1, location);
//Compute first derivatives at parametric coordinates (0.5, 0.5)
surface->D1(0.5, 0.5, p, du, dv);
//Calculate surface normal via cross product of derivatives
AMCAX::Vector3 normal = du.Cross(dv);
std::cout << "normal:" << normal << std::endl;//-1 0 0
virtual AMCAX_API void D1(double u, double v, Point3 &p, Vector3 &d1u, Vector3 &d1v) const =0
Compute the point and the first partial derivatives at given parameters.
Class of local transformation representing location of entities.
Definition TopoLocation.hpp:14
static AMCAX_API const std::shared_ptr< Geom3Surface > & Surface(const TopoFace &f, TopoLocation &l)
Get the surface and the location of the surface from a face.
constexpr auto Cross(const VectorT< OtherScalar, DIM > &other) const noexcept
2D Cross product operator
Definition VectorT.hpp:428
VectorT< double, 3 > Vector3
3D vector
Definition VectorT.hpp:707

Shell

Reversing a Shell changes the direction of the region it encloses to the opposite direction. Reversing a Shell is equivalent to reversing the Orientation of each Face in the Forward Shell.

//Make a box
AMCAX::MakeBox box(AMCAX::Point3(-5.0, -5.0, 0.0), AMCAX::Point3(5.0, 5.0, 3.0));
//Get the shell from box
AMCAX::TopoShell shell = box.Shell();
//Get the face from shell
AMCAX::TopoExplorerTool::MapShapes(shell, AMCAX::ShapeType::Face, faceSet);
std::cout << int(face1.Orientation()) << std::endl;//1
//Reverse the orientation of the shell
//Get the face from reshell
AMCAX::TopoExplorerTool::MapShapes(reshell, AMCAX::ShapeType::Face, refaceSet);
AMCAX::TopoFace reface1 = AMCAX::TopoCast::Face(refaceSet[0]);
std::cout << int(reface1.Orientation()) << std::endl;//0
static AMCAX_API const TopoShell & Shell(const TopoShape &s)
Cast shape to shell.
Class of shell.
Definition TopoShell.hpp:12

Solid

Reversing a Solid changes the direction of the region it encloses to the opposite direction. Reversing a Solid is equivalent to reversing the Orientation of each Face in the Forward Solid.

//Make a box
AMCAX::MakeBox box(AMCAX::Point3(-5.0, -5.0, 0.0), AMCAX::Point3(5.0, 5.0, 3.0));
//Get the solid and shell from box
AMCAX::TopoSolid solid = box.Solid();
AMCAX::TopoShell shell = box.Shell();
std::cout << int(shell.Orientation()) << std::endl;//0
//Reverse the orientation of the solid
//Get the shell from resolid
AMCAX::TopoExplorerTool::MapShapes(resolid, AMCAX::ShapeType::Shell, reshellSet);
AMCAX::TopoShell reshell1 = AMCAX::TopoCast::Shell(reshellSet[0]);
std::cout << int(reshell1.Orientation()) << std::endl;//1
static AMCAX_API const TopoSolid & Solid(const TopoShape &s)
Cast shape to solid.
Class of solid.
Definition TopoSolid.hpp:12

Tolerance

Tolerance represents the amount of error in a TopoShape. For example, a vertex on the curve of Edge1 is at Point3(0.0, 0.0, 0.0), and the same vertex on the curve of Edge2 is at Point3(1.0, 0.0, 0.0). With a tolerance of 2.0, these two points can be considered as the same point. In other words, although the geometric points of this vertex on different edges are different, it is still valid as a topological structure.
To obtain the Tolerance of a TopoShape, the method is: AMCAX::TopoTool::Tolerance(). Only structures containing geometric information, such as Vertex, Edge, and Face, have Tolerance. To change the Tolerance, the methods are: AMCAX::TopoBuilder::UpdateVertex(), AMCAX::TopoBuilder::UpdateEdge(), AMCAX::TopoBuilder::UpdateFace().

Next, we will introduce the Tolerance for Vertex, Edge, and Face in turn:

Vertex

The Tolerance of a Vertex is a predefined value. Its significance is that when the distance from a Point to the Vertex (i.e., the distance from the Point to the Point within the Vertex) is less than or equal to the Tolerance, the Point is considered to lie on the Vertex. The Point in a Vertex can come from various sources: the Point3 itself, the value of a Curve at a certain parameter, or the value of a Surface at certain u,v parameters. The Tolerance of the Vertex must be no less than the maximum distance between these points.

AMCAX::Point3 p1(0., 0., 0.);
auto circle = std::make_shared<AMCAX::Geom3Circle>(AMCAX::Frame3(), 1.0);
//Get the first parameter
double fp = circle->FirstParameter();
//Get the first point
AMCAX::Point3 p2 = circle->Value(fp);
//Make a vertex , and the tolerance is 2.0
builder.MakeVertex(v1, p1, 2.0);
builder.MakeVertex(v2, p2, 2.0);
std::cout << AMCAX::TopoTool::Tolerance(v1);//2.0
std::cout << AMCAX::TopoTool::Tolerance(v2);//2.0
//Update the tolerance
double tol = 2.5;
builder.UpdateVertex(v1, p1, tol);
builder.UpdateVertex(v2, p2, tol);
std::cout << AMCAX::TopoTool::Tolerance(v1);//2.5
std::cout << AMCAX::TopoTool::Tolerance(v2);//2.5
AMCAX_API void MakeVertex(TopoVertex &v) const
Make an empty vertex.
AMCAX_API void UpdateVertex(const TopoVertex &v, const Point3 &p, double tol) const
Update the point of a vertex.
static AMCAX_API double Tolerance(const TopoFace &f)
Get the tolerance of the face.

Edge

The Tolerance of an Edge is a predefined value. Its significance is that when the distance from a Point to the Edge is less than or equal to the Tolerance, the Point is considered to lie on the Edge. Additionally, an Edge has a curve3d and a pcurve, where the pcurve can be used to construct an equivalent curve3d through a Surface. The maximum distance between multiple curve3d samples must not exceed the Tolerance of the Edge. If this condition is not met, the Tolerance of the Edge must be increased. Furthermore, the Tolerance of a Vertex must be greater than or equal to the Tolerance of the Edge it lies on.

AMCAX::Point3 p1(0., 0., 0.);
auto circle = std::make_shared<AMCAX::Geom3Circle>(AMCAX::Frame3(), 1.0);
//Get the first parameter
double fp = circle->FirstParameter();
//Get the first point
AMCAX::Point3 p2 = circle->Value(fp);
//Make a vertex , and the tolerance is 2.0
builder.MakeVertex(v1, p1, 2.0);
builder.MakeVertex(v2, p2, 2.0);
//Make a edge
AMCAX::MakeEdge e(v1, v2);
AMCAX::TopoEdge edge = e.Edge();
std::cout << AMCAX::TopoTool::Tolerance(edge);//1e-7
//Update the tolerance
builder.UpdateEdge(edge, 1.0);
std::cout << AMCAX::TopoTool::Tolerance(edge);//1.0
Class of making an edge.
Definition MakeEdge.hpp:26
AMCAX_API void UpdateEdge(const TopoEdge &e, const std::shared_ptr< Geom3Curve > &c, double tol) const
Update the curve and tolerance of an edge.

Face

The Tolerance of a Face is a predefined value. Its significance is that when the distance from a Point to the Face is less than or equal to the Tolerance, the Point is considered to lie on the Face. This is often used in Boolean operations. Additionally, the Tolerance of a Vertex or Edge must be greater than or equal to the Tolerance of the Face they lie on.

AMCAX::Geom3Plane plane(frame);
//Make a face
AMCAX::TopoFace face = AMCAX::MakeFace(plane.GetPlane(), 0., 2., 0., 2.);
std::cout << AMCAX::TopoTool::Tolerance(face);//1e-7
//Update the tolerance
builder.UpdateFace(face, 0.5);
std::cout << AMCAX::TopoTool::Tolerance(face);//0.5
Class of 3D plane.
Definition Geom3Plane.hpp:14
Class of making a face.
Definition MakeFace.hpp:24
AMCAX_API void UpdateFace(const TopoFace &f, const std::shared_ptr< Geom3Surface > &s, const TopoLocation &l, double tol) const
Update the surface, location and tolerance of a face.

Note: When there is a dependency relationship, the Tolerance of a Vertex must be greater than or equal to the Tolerance of an Edge, and the Tolerance of an Edge must be greater than or equal to the Tolerance of a Face.

Closed

Whether a TopoShape is closed is a crucial flag. We can use AMCAX::TopoTool::IsClosed() to determine if a TopoShape is closed. This should be distinguished from AMCAX::TopoShape::Closed(), which returns a boolean flag that can be arbitrarily defined by the user. For example, even if a line segment is constructed into an Edge that is not closed, it can still be set as closed using AMCAX::TopoShape::Closed(true).

AMCAX::Point3 p1(1.0, 0.0, 0.0);
edge.Closed(true);
std::cout << edge.Closed() << std::endl;//1
std::cout << AMCAX::TopoTool::IsClosed(edge) << std::endl;//0
AMCAX_API bool Closed() const noexcept
Is the shape closed.

On the other hand, AMCAX::TopoTool::IsClosed() performs a topological check on certain types of TopoShape. Below is an explanation of how AMCAX::TopoTool::IsClosed() works for different ShapeType inputs.

Edge

AMCAX::TopoTool::IsClosed() is used to determine whether the FirstVertex and LastVertex of an Edge are the same (IsSame).

auto c = std::make_shared<AMCAX::Geom3Circle>(AMCAX::Frame3(), 1.0);
AMCAX::TopoEdge edge1 = AMCAX::MakeEdge(c, v1, v1);
std::cout << AMCAX::TopoTool::IsClosed(edge1) << std::endl;//1

Wire

AMCAX::TopoTool::IsClosed() is used to determine whether a Wire has no boundary Vertex, meaning that each Vertex in the Wire appears an even number of times.

AMCAX::MakePolygon polygon(AMCAX::Point3(-1., -1., 0.), AMCAX::Point3(1., -1., 0.), AMCAX::Point3(1., 1., 0.), AMCAX::Point3(-1., 1., 0.),true);
AMCAX::TopoWire w = polygon.Wire();
std::cout << AMCAX::TopoTool::IsClosed(w) << std::endl;//1
Class of making a polygon.
Definition MakePolygon.hpp:20

Shell

AMCAX::TopoTool::IsClosed() is used to determine whether a Shell has no boundary Edge (free Edge), meaning that each Edge in the Shell (excluding degenerate edges) appears an even number of times.

AMCAX::MakeBox box(2., 2., 2.);
AMCAX::TopoShell shell = box.Shell();
std::cout << AMCAX::TopoTool::IsClosed(shell) << std::endl;//1

Others

For TopoShape types other than Edge, Wire, and Shell, the result of AMCAX::TopoTool::IsClosed() is the same as the result of AMCAX::TopoShape::Closed().

//Make a box
AMCAX::MakeBox box(2., 2., 2.);
//1. Solid
AMCAX::TopoSolid solid = box.Solid();
//Set open
solid.Closed(false);
std::cout << solid.Closed() << std::endl;//0
std::cout << AMCAX::TopoTool::IsClosed(solid) << std::endl;//0
//Set closed
solid.Closed(true);
std::cout << solid.Closed() << std::endl;//1
std::cout << AMCAX::TopoTool::IsClosed(solid) << std::endl;//1
//2. Face
AMCAX::TopoExplorerTool::MapShapes(box, AMCAX::ShapeType::Face, FaceSet);
//Set open
face1.Closed(false);
std::cout << face1.Closed() << std::endl;//0
std::cout << AMCAX::TopoTool::IsClosed(face1) << std::endl;//0
//Set closed
face1.Closed(true);
std::cout << face1.Closed() << std::endl;//1
std::cout << AMCAX::TopoTool::IsClosed(face1) << std::endl;//1