Warnings on vc14 were eliminated
[occt.git] / src / MeshTest / MeshTest_Debug.cxx
CommitLineData
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
16#include <BRepMesh_FaceAttribute.hxx>
17#include <Draw_Segment3D.hxx>
18#include <DrawTrSurf_Polygon3D.hxx>
19#include <Draw.hxx>
20#include <TCollection_AsciiString.hxx>
21#include <TColgp_Array1OfPnt.hxx>
22#include <Poly_Polygon3D.hxx>
23
24// This file defines global functions not declared in any public header,
25// intended for use from debugger prompt (Command Window in Visual Studio)
26
27//=======================================================================
28//function : MeshTest_DrawLinks
29//purpose : Draw links from mesh data structure of type BRepMesh_FaceAttribute
30//=======================================================================
31Standard_EXPORT const char* MeshTest_DrawLinks(const char* theNameStr, void* theFaceAttr)
32{
33 if (theNameStr == 0 || theFaceAttr == 0)
34 {
35 return "Error: name or face attribute is null";
36 }
37 try {
38 const Handle(BRepMesh_FaceAttribute)& aFaceAttr = *(Handle(BRepMesh_FaceAttribute)*)theFaceAttr;
39 const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData = aFaceAttr->ChangeStructure();
40 if (aMeshData.IsNull())
41 return "Null mesh data structure";
42 Standard_Integer nbLinks = aMeshData->NbLinks();
43 cout << "nblink=" << nbLinks << endl;
44 TCollection_AsciiString aName(theNameStr);
45 for (Standard_Integer i = 1; i <= nbLinks; i++)
46 {
47 const BRepMesh_Edge& aLink = aMeshData->GetLink(i);
48 if (aLink.Movability() == BRepMesh_Deleted)
49 continue;
50 Standard_Integer n1 = aLink.FirstNode();
51 Standard_Integer n2 = aLink.LastNode();
52 const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n1);
53 const BRepMesh_Vertex& aV2 = aMeshData->GetNode(n2);
54 const gp_Pnt& aP1 = aFaceAttr->GetPoint(aV1);
55 const gp_Pnt& aP2 = aFaceAttr->GetPoint(aV2);
56 Handle(Draw_Segment3D) aSeg = new Draw_Segment3D(aP1, aP2, Draw_bleu);
57 Draw::Set((aName + "_" + i).ToCString(), aSeg);
58 }
59 return theNameStr;
60 }
9775fa61 61 catch (Standard_Failure const& anException)
81093856 62 {
9775fa61 63 return anException.GetMessageString();
81093856 64 }
65}
66
67//=======================================================================
68//function : MeshTest_DrawTriangles
69//purpose : Draw triangles from mesh data structure of type BRepMesh_FaceAttribute
70//=======================================================================
71Standard_EXPORT const char* MeshTest_DrawTriangles(const char* theNameStr, void* theFaceAttr)
72{
73 if (theNameStr == 0 || theFaceAttr == 0)
74 {
75 return "Error: name or face attribute is null";
76 }
77 try {
78 const Handle(BRepMesh_FaceAttribute)& aFaceAttr =
79 *(Handle(BRepMesh_FaceAttribute)*)theFaceAttr;
80 const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData = aFaceAttr->ChangeStructure();
81 if (aMeshData.IsNull())
82 return "Null mesh data structure";
83 Standard_Integer nbElem = aMeshData->NbElements();
84 cout << "nbelem=" << nbElem << endl;
85 TCollection_AsciiString aName(theNameStr);
86 for (Standard_Integer i = 1; i <= nbElem; i++)
87 {
88 const BRepMesh_Triangle& aTri = aMeshData->GetElement(i);
89 if (aTri.Movability() == BRepMesh_Deleted)
90 continue;
91 Standard_Integer n[3];
92 aMeshData->ElementNodes(aTri, n);
93 const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n[0]);
94 const BRepMesh_Vertex& aV2 = aMeshData->GetNode(n[1]);
95 const BRepMesh_Vertex& aV3 = aMeshData->GetNode(n[2]);
96 gp_Pnt aP[4] = { aFaceAttr->GetPoint(aV1), aFaceAttr->GetPoint(aV2),
97 aFaceAttr->GetPoint(aV3), aFaceAttr->GetPoint(aV1) };
98 TColgp_Array1OfPnt aPnts(aP[0], 1, 4);
99 Handle(Poly_Polygon3D) aPoly = new Poly_Polygon3D(aPnts);
100 Handle(DrawTrSurf_Polygon3D) aDPoly = new DrawTrSurf_Polygon3D(aPoly);
101 Draw::Set((aName + "_" + i).ToCString(), aDPoly);
102 }
103 return theNameStr;
104 }
9775fa61 105 catch (Standard_Failure const& anException)
81093856 106 {
9775fa61 107 return anException.GetMessageString();
81093856 108 }
109}