b311480e |
1 | // Created on: 1996-06-21 |
2 | // Created by: Bruno TACCI |
3 | // Copyright (c) 1996-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | #include <StlMesh.ixx> |
23 | #include <StlMesh_SequenceOfMeshTriangle.hxx> |
24 | #include <StlMesh_MeshTriangle.hxx> |
25 | #include <TColgp_SequenceOfXYZ.hxx> |
26 | |
27 | //======================================================================= |
28 | //function : Merge |
29 | //purpose : |
30 | //======================================================================= |
31 | |
32 | Handle(StlMesh_Mesh) StlMesh::Merge(const Handle(StlMesh_Mesh)& mesh1, const Handle(StlMesh_Mesh)& mesh2) |
33 | { |
34 | Handle(StlMesh_Mesh) mergeMesh = new StlMesh_Mesh; |
35 | StlMesh_SequenceOfMeshTriangle aSeqOfTriangle; |
36 | TColgp_SequenceOfXYZ aSeqOfVertex; |
37 | Standard_Real xn,yn,zn; |
38 | Standard_Integer v1,v2,v3; |
39 | |
40 | // Chargement de mesh1 dans mergeMesh |
41 | // Boucle sur les domaines puis sur les triangles |
42 | |
43 | Standard_Integer idom; |
44 | for (idom = 1; idom <= mesh1->NbDomains(); idom++) { |
45 | aSeqOfTriangle = mesh1->Triangles(idom); |
46 | aSeqOfVertex = mesh1->Vertices(idom); |
47 | mergeMesh->AddDomain(mesh1->Deflection(idom)); |
48 | |
49 | for (Standard_Integer itri = 1; itri <= mesh1->NbTriangles(idom); itri++) { |
50 | const Handle(StlMesh_MeshTriangle) aTrian = aSeqOfTriangle.Value(itri); |
51 | aTrian->GetVertexAndOrientation(v1,v2,v3,xn,yn,zn); |
52 | mergeMesh->AddTriangle(v1,v2,v3,xn,yn,zn); |
53 | } |
54 | |
55 | for (Standard_Integer iver = 1; iver <= mesh1->NbVertices(idom); iver++) { |
56 | mergeMesh->AddVertex(aSeqOfVertex.Value(iver).X(), |
57 | aSeqOfVertex.Value(iver).Y(), |
58 | aSeqOfVertex.Value(iver).Z()); |
59 | } |
60 | |
61 | } |
62 | // Idem avec mesh2 |
63 | |
64 | for (idom = 1; idom <= mesh2->NbDomains(); idom++) { |
65 | aSeqOfTriangle = mesh2->Triangles(idom); |
66 | aSeqOfVertex = mesh2->Vertices(idom); |
67 | mergeMesh->AddDomain(mesh2->Deflection(idom)); |
68 | |
69 | for (Standard_Integer itri = 1; itri <= mesh2->NbTriangles(idom); itri++) { |
70 | const Handle(StlMesh_MeshTriangle) aTrian = aSeqOfTriangle.Value(itri); |
71 | aTrian->GetVertexAndOrientation(v1,v2,v3,xn,yn,zn); |
72 | mergeMesh->AddTriangle(v1,v2,v3,xn,yn,zn); |
73 | } |
74 | |
75 | for (Standard_Integer iver = 1; iver <= mesh2->NbVertices(idom); iver++) { |
76 | mergeMesh->AddVertex(aSeqOfVertex.Value(iver).X(), |
77 | aSeqOfVertex.Value(iver).Y(), |
78 | aSeqOfVertex.Value(iver).Z()); |
79 | } |
80 | } |
81 | return mergeMesh; |
82 | } |