81093856 |
1 | // Created on: 2016-05-31 |
2 | // Created by: Mikhail Sazonov |
3 | // Copyright (c) 2016 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
81093856 |
16 | #include <Draw_Segment3D.hxx> |
17 | #include <DrawTrSurf_Polygon3D.hxx> |
18 | #include <Draw.hxx> |
19 | #include <TCollection_AsciiString.hxx> |
20 | #include <TColgp_Array1OfPnt.hxx> |
21 | #include <Poly_Polygon3D.hxx> |
7bd071ed |
22 | #include <BRepMesh_Edge.hxx> |
23 | #include <BRepMesh_Vertex.hxx> |
24 | #include <BRepMesh_Triangle.hxx> |
25 | #include <BRepMesh_DataStructureOfDelaun.hxx> |
81093856 |
26 | |
27 | // This file defines global functions not declared in any public header, |
28 | // intended for use from debugger prompt (Command Window in Visual Studio) |
29 | |
30 | //======================================================================= |
31 | //function : MeshTest_DrawLinks |
32 | //purpose : Draw links from mesh data structure of type BRepMesh_FaceAttribute |
33 | //======================================================================= |
7bd071ed |
34 | Standard_EXPORT const char* MeshTest_DrawLinks(const char* theNameStr, void* theDataStruct) |
81093856 |
35 | { |
7bd071ed |
36 | if (theNameStr == 0 || theDataStruct == 0) |
81093856 |
37 | { |
38 | return "Error: name or face attribute is null"; |
39 | } |
40 | try { |
7bd071ed |
41 | const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData = *(Handle(BRepMesh_DataStructureOfDelaun)*)theDataStruct; |
81093856 |
42 | if (aMeshData.IsNull()) |
43 | return "Null mesh data structure"; |
44 | Standard_Integer nbLinks = aMeshData->NbLinks(); |
04232180 |
45 | std::cout << "nblink=" << nbLinks << std::endl; |
81093856 |
46 | TCollection_AsciiString aName(theNameStr); |
47 | for (Standard_Integer i = 1; i <= nbLinks; i++) |
48 | { |
49 | const BRepMesh_Edge& aLink = aMeshData->GetLink(i); |
50 | if (aLink.Movability() == BRepMesh_Deleted) |
51 | continue; |
52 | Standard_Integer n1 = aLink.FirstNode(); |
53 | Standard_Integer n2 = aLink.LastNode(); |
54 | const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n1); |
55 | const BRepMesh_Vertex& aV2 = aMeshData->GetNode(n2); |
7bd071ed |
56 | Handle(Draw_Segment3D) aSeg = new Draw_Segment3D(gp_Pnt(aV1.Coord().X(), aV1.Coord().Y(), 0), |
57 | gp_Pnt(aV2.Coord().X(), aV2.Coord().Y(), 0), |
58 | Draw_bleu); |
81093856 |
59 | Draw::Set((aName + "_" + i).ToCString(), aSeg); |
60 | } |
61 | return theNameStr; |
62 | } |
9775fa61 |
63 | catch (Standard_Failure const& anException) |
81093856 |
64 | { |
9775fa61 |
65 | return anException.GetMessageString(); |
81093856 |
66 | } |
67 | } |
68 | |
69 | //======================================================================= |
70 | //function : MeshTest_DrawTriangles |
71 | //purpose : Draw triangles from mesh data structure of type BRepMesh_FaceAttribute |
72 | //======================================================================= |
7bd071ed |
73 | Standard_EXPORT const char* MeshTest_DrawTriangles(const char* theNameStr, void* theDataStruct) |
81093856 |
74 | { |
7bd071ed |
75 | if (theNameStr == 0 || theDataStruct == 0) |
81093856 |
76 | { |
77 | return "Error: name or face attribute is null"; |
78 | } |
79 | try { |
7bd071ed |
80 | const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData = |
81 | *(Handle(BRepMesh_DataStructureOfDelaun)*)theDataStruct; |
82 | |
81093856 |
83 | if (aMeshData.IsNull()) |
84 | return "Null mesh data structure"; |
85 | Standard_Integer nbElem = aMeshData->NbElements(); |
04232180 |
86 | std::cout << "nbelem=" << nbElem << std::endl; |
81093856 |
87 | TCollection_AsciiString aName(theNameStr); |
88 | for (Standard_Integer i = 1; i <= nbElem; i++) |
89 | { |
90 | const BRepMesh_Triangle& aTri = aMeshData->GetElement(i); |
91 | if (aTri.Movability() == BRepMesh_Deleted) |
92 | continue; |
93 | Standard_Integer n[3]; |
94 | aMeshData->ElementNodes(aTri, n); |
95 | const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n[0]); |
96 | const BRepMesh_Vertex& aV2 = aMeshData->GetNode(n[1]); |
97 | const BRepMesh_Vertex& aV3 = aMeshData->GetNode(n[2]); |
7bd071ed |
98 | gp_Pnt aP[4] = { gp_Pnt(aV1.Coord().X(), aV1.Coord().Y(), 0), |
99 | gp_Pnt(aV2.Coord().X(), aV2.Coord().Y(), 0), |
100 | gp_Pnt(aV3.Coord().X(), aV3.Coord().Y(), 0), |
101 | gp_Pnt(aV1.Coord().X(), aV1.Coord().Y(), 0) }; |
81093856 |
102 | TColgp_Array1OfPnt aPnts(aP[0], 1, 4); |
103 | Handle(Poly_Polygon3D) aPoly = new Poly_Polygon3D(aPnts); |
104 | Handle(DrawTrSurf_Polygon3D) aDPoly = new DrawTrSurf_Polygon3D(aPoly); |
105 | Draw::Set((aName + "_" + i).ToCString(), aDPoly); |
106 | } |
107 | return theNameStr; |
108 | } |
9775fa61 |
109 | catch (Standard_Failure const& anException) |
81093856 |
110 | { |
9775fa61 |
111 | return anException.GetMessageString(); |
81093856 |
112 | } |
113 | } |