0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / QABugs / QABugs_5.cxx
CommitLineData
b311480e 1// Created on: 2004-06-25
2// Created by: QA Admin (qa)
973c2be1 3// Copyright (c) 2004-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
1cd84fee 16#include <QABugs.hxx>
7fd59977 17
18#include <Draw_Interpretor.hxx>
c22b52d6 19#include <Adaptor3d_Curve.hxx>
7fd59977 20#include <DrawTrSurf.hxx>
7fd59977 21#include <DBRep.hxx>
c22b52d6 22#include <GeomAdaptor_Surface.hxx>
7fd59977 23#include <TopoDS.hxx>
c22b52d6 24#include <BRepAdaptor_CompCurve.hxx>
7fd59977 25#include <IntCurveSurface_HInter.hxx>
26#include <IntCurveSurface_IntersectionPoint.hxx>
27#include <TopoDS_Edge.hxx>
28#include <BRepBuilderAPI_MakeEdge.hxx>
29#include <BRepBuilderAPI_MakeWire.hxx>
30#include <Standard_ErrorHandler.hxx>
31
32#include <stdio.h>
33#include <stdlib.h>
34
35static Standard_Integer OCC6001 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
36{
37 if (argc < 4)
38 {
586db386 39 di<<"missing parameters\n";
7fd59977 40 return 1;
41 }
42 const char *name = argv[1];
c22b52d6 43 Handle(Adaptor3d_Curve) hcurve;
7fd59977 44 Handle(Geom_Curve) curve = DrawTrSurf::GetCurve(argv[2]);
45 if (!curve.IsNull())
c22b52d6 46 hcurve = new GeomAdaptor_Curve(curve);
7fd59977 47 else
48 {
49 TopoDS_Shape wire = DBRep::Get(argv[2]);
50 if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
51 {
586db386 52 di<<"incorrect 1st parameter, curve or wire expected\n";
7fd59977 53 return 1;
54 }
55 BRepAdaptor_CompCurve comp_curve(TopoDS::Wire(wire));
c22b52d6 56 hcurve = new BRepAdaptor_CompCurve(comp_curve);
7fd59977 57 }
58 Handle(Geom_Surface) surf = DrawTrSurf::GetSurface(argv[3]);
c22b52d6 59 Handle(GeomAdaptor_Surface) hsurf = new GeomAdaptor_Surface(surf);
7fd59977 60 IntCurveSurface_HInter inter;
61 inter.Perform(hcurve, hsurf);
62 int nb = inter.NbPoints();
63 if (!inter.IsDone() || nb == 0)
64 {
65 di<<"no intersections";
66 return 0;
67 }
68 for (int i=1; i <= nb; i++)
69 {
70 const IntCurveSurface_IntersectionPoint &int_pnt = inter.Point(i);
71 double par = int_pnt.W();
72 gp_Pnt p = int_pnt.Pnt();
73 di<<"inter "<<i<<": W = "<<par<<"\n"
74 <<"\tpnt = "<<p.X()<<" "<<p.Y()<<" "<<p.Z()<<"\n";
75 char n[20], *pname=n;
91322f44 76 Sprintf(n,"%s_%d",name,i);
7fd59977 77 DrawTrSurf::Set(pname,p);
78 }
79
80 return 0;
81
82}
83
84static Standard_Integer OCC5696 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
85{
86 if (argc != 1)
87 {
88 di << "Usage : " << argv[0] << "\n";
89 return 1;
90 }
91 TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(gp_Pnt(0,0,0),gp_Pnt(2,0,0));
92 TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edge);
93 BRepAdaptor_CompCurve curve(wire);
94 Standard_Real first = curve.FirstParameter();
95 Standard_Real last = curve.LastParameter();
96 Standard_Real par = (first + last)/2;
97 Standard_Real par_edge;
98 TopoDS_Edge edge_found;
99 try {
100 OCC_CATCH_SIGNALS
101 curve.Edge(par,edge_found,par_edge); // exception is here
102 di << "par_edge = " << par_edge << "\n";
103 }
104
a738b534 105 catch (Standard_Failure const&) {di << "OCC5696 Exception \n" ;return 0;}
7fd59977 106
107 return 0;
108}
109
1cd84fee 110void QABugs::Commands_5(Draw_Interpretor& theCommands) {
1365140b 111 const char *group = "QABugs";
7fd59977 112
113 theCommands.Add ("OCC6001", "OCC6001 name curve/wire surface\n\t\tintersect curve by surface",
114 __FILE__, OCC6001, group);
115
116 theCommands.Add ("OCC5696", "OCC5696",
117 __FILE__, OCC5696, group);
118
119 return;
120}