4952a30a |
1 | -- File: Poly.cdl |
7fd59977 |
2 | -- Created: Mon Mar 6 09:38:50 1995 |
3 | -- Author: Laurent PAINNOT |
4 | -- <lpa@metrox> |
5 | ---Copyright: Matra Datavision 1995 |
6 | |
7 | |
8 | |
4952a30a |
9 | package Poly |
7fd59977 |
10 | |
11 | ---Purpose: This package provides classes and services to |
12 | -- handle : |
4952a30a |
13 | -- |
7fd59977 |
14 | -- * 3D triangular polyhedrons. |
4952a30a |
15 | -- |
7fd59977 |
16 | -- * 3D polygons. |
4952a30a |
17 | -- |
7fd59977 |
18 | -- * 2D polygon. |
4952a30a |
19 | -- |
7fd59977 |
20 | -- * Tools to dump, save and restore those objects. |
21 | |
22 | uses |
23 | |
24 | MMgt, |
25 | TCollection, |
26 | TColStd, |
27 | gp, |
4952a30a |
28 | TColgp, |
7fd59977 |
29 | TShort |
30 | |
31 | is |
32 | |
33 | class Triangle; |
34 | ---Purpose: A triangle is a triplet of integers (indices of |
35 | -- the nodes). |
36 | |
37 | class Array1OfTriangle |
38 | instantiates Array1 from TCollection(Triangle from Poly); |
4952a30a |
39 | |
7fd59977 |
40 | class HArray1OfTriangle |
41 | instantiates HArray1 from TCollection(Triangle from Poly, |
42 | Array1OfTriangle from Poly); |
43 | |
44 | class Triangulation; |
45 | ---Purpose: A Triangulation is a 3D polyhedron made of |
46 | -- triangles. It is made of a nodes which are |
47 | -- indexed. Nodes have a 3d value and a 2d value. |
48 | -- Triangles are triplet of node indices. |
4952a30a |
49 | -- |
7fd59977 |
50 | -- This is a Transient class. |
51 | |
52 | |
53 | class Polygon3D; |
54 | ---Purpose: A Polygon3D is made of indexed nodes. |
55 | -- Nodes have a 3d value. |
56 | |
57 | class Polygon2D; |
58 | ---Purpose: A Polygon2D is made of indexed nodes. |
59 | -- Nodes have a 2d value. |
60 | |
61 | class PolygonOnTriangulation; |
62 | ---Purpose: A polygonOnTriangulation is made of node indices |
63 | -- referencing a triangulation. |
64 | |
65 | |
4952a30a |
66 | -- |
7fd59977 |
67 | -- Tools to use triangulations |
4952a30a |
68 | -- |
69 | |
7fd59977 |
70 | class Connect; |
71 | ---Purpose: Computes and stores the link from nodes to |
72 | -- triangles and from triangles to neighbouring |
73 | -- triangles. |
74 | -- This tool is obsolete, replaced by Poly_CoherentTriangulation |
75 | |
76 | -- |
77 | -- Data types for the Coherent Triangulation data model |
78 | -- |
79 | imported CogerentTriangulation; |
80 | imported CoherentTriangle; |
81 | imported CoherentNode; |
82 | imported CoherentLink; |
83 | imported CoherentTriPtr; |
84 | imported ListOfTriangulation; |
85 | |
86 | imported MakeLoops; |
87 | ---Purpose: Algorithm to make minimal loops in a graph |
88 | |
89 | -- |
90 | -- Package methods |
4952a30a |
91 | -- |
92 | |
7fd59977 |
93 | Catenate (lstTri: ListOfTriangulation from Poly) |
94 | returns Triangulation from Poly; |
95 | ---Purpose: Join several triangulations to one new triangulation object. |
96 | -- The new triangulation is just a mechanical sum of input |
97 | -- triangulations, without node sharing. UV coordinates are |
98 | -- dropped in the result. |
99 | |
100 | Write(T : Triangulation from Poly; |
101 | OS : in out OStream; |
102 | Compact : Boolean = Standard_True); |
4952a30a |
103 | |
7fd59977 |
104 | ---Purpose: Writes the content of the triangulation <T> on the |
105 | -- stream <OS>. If <Compact> is true this is a "save" |
106 | -- format intended to be read back with the Read |
107 | -- method. If compact is False it is a "Dump" format |
108 | -- intended to be informative. |
109 | |
110 | Write(P : Polygon3D from Poly; |
111 | OS : in out OStream; |
112 | Compact : Boolean = Standard_True); |
4952a30a |
113 | |
7fd59977 |
114 | ---Purpose: Writes the content of the 3D polygon <P> on the |
115 | -- stream <OS>. If <Compact> is true this is a "save" |
116 | -- format intended to be read back with the Read |
117 | -- method. If compact is False it is a "Dump" format |
118 | -- intended to be informative. |
119 | |
120 | Write(P : Polygon2D from Poly; |
121 | OS : in out OStream; |
122 | Compact : Boolean = Standard_True); |
4952a30a |
123 | |
7fd59977 |
124 | ---Purpose: Writes the content of the 2D polygon <P> on the |
125 | -- stream <OS>. If <Compact> is true this is a "save" |
126 | -- format intended to be read back with the Read |
127 | -- method. If compact is False it is a "Dump" format |
128 | -- intended to be informative. |
129 | |
130 | |
131 | Dump(T : Triangulation from Poly; |
132 | OS : in out OStream); |
133 | ---Purpose: Dumps the triangulation. This is a call to the |
134 | -- previous method with Comapct set to False. |
4952a30a |
135 | |
7fd59977 |
136 | Dump(P : Polygon3D from Poly; |
137 | OS : in out OStream); |
138 | ---Purpose: Dumps the 3D polygon. This is a call to the |
139 | -- previous method with Comapct set to False. |
4952a30a |
140 | |
7fd59977 |
141 | Dump(P : Polygon2D from Poly; |
142 | OS : in out OStream); |
143 | ---Purpose: Dumps the 2D polygon. This is a call to the |
144 | -- previous method with Comapct set to False. |
4952a30a |
145 | |
7fd59977 |
146 | |
147 | ReadTriangulation(IS : in out IStream) |
148 | returns Triangulation from Poly; |
149 | ---Purpose: Reads a triangulation from the stream <IS>. |
4952a30a |
150 | |
7fd59977 |
151 | ReadPolygon3D(IS : in out IStream) |
152 | returns Polygon3D from Poly; |
153 | ---Purpose: Reads a 3d polygon from the stream <IS>. |
4952a30a |
154 | |
7fd59977 |
155 | ReadPolygon2D(IS : in out IStream) |
156 | returns Polygon2D from Poly; |
157 | ---Purpose: Reads a 2D polygon from the stream <IS>. |
158 | |
159 | ComputeNormals(Tri : Triangulation from Poly); |
4952a30a |
160 | ---Purpose: Compute node normals for face triangulation |
7fd59977 |
161 | -- as mean normal of surrounding triangles |
4952a30a |
162 | |
163 | PointOnTriangle(P1, P2, P3, P: XY from gp; UV: out XY from gp) |
164 | returns Real; |
165 | ---Purpose: Computes parameters of the point P on triangle |
166 | -- defined by points P1, P2, and P3, in 2d. |
167 | -- The parameters U and V are defined so that |
168 | -- P = P1 + U * (P2 - P1) + V * (P3 - P1), |
169 | -- with U >= 0, V >= 0, U + V <= 1. |
170 | -- If P is located outside of triangle, or triangle |
171 | -- is degenerated, the returned parameters correspond |
172 | -- to closest point, and returned value is square of |
173 | -- the distance from original point to triangle (0 if |
174 | -- point is inside). |
175 | |
7fd59977 |
176 | end Poly; |