b311480e |
1 | // Created on: 1995-09-25 |
2 | // Created by: Philippe GIRODENGO |
3 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | //======================================================================= |
42cf5bc1 |
18 | |
19 | #include <Standard_NoMoreObject.hxx> |
20 | #include <Standard_NoSuchObject.hxx> |
21 | #include <Standard_OutOfRange.hxx> |
22 | #include <StlMesh_Mesh.hxx> |
23 | #include <StlMesh_MeshExplorer.hxx> |
7fd59977 |
24 | #include <StlMesh_MeshTriangle.hxx> |
25 | |
26 | //======================================================================= |
27 | //function : StlMesh_MeshExplorer |
28 | //design : |
29 | //warning : |
30 | //======================================================================= |
7fd59977 |
31 | StlMesh_MeshExplorer::StlMesh_MeshExplorer(const Handle(StlMesh_Mesh)& M) |
32 | : domainIndex (0), nbTriangles (0) ,triangleIndex (0) { mesh = M;} |
33 | |
34 | |
35 | //======================================================================= |
36 | //function : Deflection |
37 | //design : |
38 | //warning : |
39 | //======================================================================= |
40 | |
41 | Standard_Real StlMesh_MeshExplorer::Deflection() const |
42 | { return mesh->Deflection (domainIndex);} |
43 | |
44 | |
45 | //======================================================================= |
46 | //function : InitTriangle |
47 | //design : |
48 | //warning : |
49 | //======================================================================= |
50 | |
51 | void StlMesh_MeshExplorer::InitTriangle(const Standard_Integer DomainIndex) |
52 | { |
53 | triangleIndex = 1; |
54 | domainIndex = DomainIndex; |
55 | nbTriangles = mesh->NbTriangles (domainIndex); |
56 | if (nbTriangles > 0) { |
57 | trianglesdef.Assign (mesh->Triangles (DomainIndex)); |
58 | trianglesVertex.Assign (mesh->Vertices (DomainIndex)); |
59 | const Handle (StlMesh_MeshTriangle) trian = trianglesdef.First(); |
60 | trian->GetVertexAndOrientation (v1,v2,v3,xn,yn,zn); |
61 | } |
62 | } |
63 | |
64 | //======================================================================= |
65 | //function : NextTriangle |
66 | //design : |
67 | //warning : |
68 | //======================================================================= |
69 | |
70 | void StlMesh_MeshExplorer::NextTriangle() |
71 | { |
72 | triangleIndex++; |
73 | if (triangleIndex <= nbTriangles) { |
74 | const Handle (StlMesh_MeshTriangle) trian = trianglesdef.Value (triangleIndex); |
75 | trian->GetVertexAndOrientation (v1,v2,v3,xn,yn,zn); |
76 | } |
77 | } |
78 | |
79 | //======================================================================= |
80 | //function : TriangleVertices |
81 | //design : |
82 | //warning : |
83 | //======================================================================= |
84 | |
85 | void StlMesh_MeshExplorer::TriangleVertices(Standard_Real& X1, Standard_Real& Y1, |
86 | Standard_Real& Z1, Standard_Real& X2, |
87 | Standard_Real& Y2, Standard_Real& Z2, |
88 | Standard_Real& X3, Standard_Real& Y3, |
89 | Standard_Real& Z3) const |
90 | { |
91 | Standard_NoSuchObject_Raise_if (triangleIndex > nbTriangles, " StlMesh_MeshExplorer::TriangleVertices"); |
92 | |
93 | X1 = (trianglesVertex.Value(v1)).X(); |
94 | Y1 = (trianglesVertex.Value(v1)).Y(); |
95 | Z1 = (trianglesVertex.Value(v1)).Z(); |
96 | X2 = (trianglesVertex.Value(v2)).X(); |
97 | Y2 = (trianglesVertex.Value(v2)).Y(); |
98 | Z2 = (trianglesVertex.Value(v2)).Z(); |
99 | X3 = (trianglesVertex.Value(v3)).X(); |
100 | Y3 = (trianglesVertex.Value(v3)).Y(); |
101 | Z3 = (trianglesVertex.Value(v3)).Z(); |
102 | } |
103 | |
104 | //======================================================================= |
105 | //function : TriangleDirection |
106 | //design : |
107 | //warning : |
108 | //======================================================================= |
109 | |
110 | void StlMesh_MeshExplorer::TriangleOrientation(Standard_Real& Xn, Standard_Real& Yn, Standard_Real& Zn) const |
111 | { |
112 | Xn = xn; |
113 | Yn = yn; |
114 | Zn = zn; |
115 | } |
116 | |
117 | |
118 | |
119 | |
120 | |
121 | |