1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <IGESSelect_RemoveCurves.ixx>
15 #include <Interface_Macros.hxx>
16 #include <IGESGeom_TrimmedSurface.hxx>
17 #include <IGESGeom_BoundedSurface.hxx>
18 #include <IGESGeom_CurveOnSurface.hxx>
19 #include <IGESGeom_Boundary.hxx>
20 #include <IGESData_IGESEntity.hxx>
21 #include <IGESData_HArray1OfIGESEntity.hxx>
22 #include <IGESBasic_HArray1OfHArray1OfIGESEntity.hxx>
23 #include <TColStd_HArray1OfInteger.hxx>
27 IGESSelect_RemoveCurves::IGESSelect_RemoveCurves (const Standard_Boolean UV)
28 : IGESSelect_ModelModifier (Standard_True) , theUV (UV) { }
30 static Standard_Boolean Edit
31 (const Handle(Standard_Transient)& ent, const Standard_Boolean UV)
33 Standard_Boolean res = Standard_False;
34 DeclareAndCast(IGESGeom_TrimmedSurface,trsu,ent);
36 res = Edit (trsu->OuterContour(),UV);
37 Standard_Integer i,nb = trsu->NbInnerContours();
38 for (i = 1; i <= nb; i ++) {
39 res = res | Edit (trsu->InnerContour(i),UV);
44 DeclareAndCast(IGESGeom_BoundedSurface,bnsu,ent);
46 Standard_Integer i,nb = bnsu->NbBoundaries();
47 for (i = 1; i <= nb; i ++) {
48 res = res | Edit (bnsu->Boundary(i),UV);
53 DeclareAndCast(IGESGeom_CurveOnSurface,cons,ent);
55 Handle(IGESData_IGESEntity) cuv,c3d;
56 cuv = cons->CurveUV();
57 c3d = cons->Curve3D();
58 Standard_Integer pref = cons->PreferenceMode();
59 if (UV && !c3d.IsNull()) {
60 if (cuv.IsNull() || c3d.IsNull()) return Standard_False; // rien a faire
62 if (pref == 1) pref = 0;
63 if (pref == 3) pref = 2;
64 } else if (!cuv.IsNull()) {
65 if (cuv.IsNull() || c3d.IsNull()) return Standard_False; // rien a faire
67 if (pref == 2) pref = 0;
68 if (pref == 3) pref = 1;
70 cons->Init ( cons->CreationMode(), cons->Surface(), cuv, c3d, pref );
74 DeclareAndCast(IGESGeom_Boundary,bndy,ent);
76 Standard_Integer i, nb = bndy->NbModelSpaceCurves();
77 if (nb == 0) return Standard_False;
78 Handle(IGESData_HArray1OfIGESEntity) arc3d = new IGESData_HArray1OfIGESEntity(1,nb);
79 Handle(IGESBasic_HArray1OfHArray1OfIGESEntity) arcuv = new IGESBasic_HArray1OfHArray1OfIGESEntity (1,nb);
80 Handle(TColStd_HArray1OfInteger) sens = new TColStd_HArray1OfInteger(1,nb);
81 for (i = 1; i <= nb; i ++) {
82 sens->SetValue (i,bndy->Sense(i));
83 Handle(IGESData_HArray1OfIGESEntity) cuv = bndy->ParameterCurves(i);
84 Handle(IGESData_IGESEntity) c3d = bndy->ModelSpaceCurve (i);
86 if (cuv.IsNull() || c3d.IsNull()) continue; // rien a faire
88 arcuv->SetValue (i,cuv);
90 if (cuv.IsNull() || c3d.IsNull()) continue; // rien a faire
92 arc3d->SetValue (i,c3d);
96 // Y a-t-il eu de la retouche ?
97 Standard_Integer pref = bndy->PreferenceType();
99 if (pref == 2) pref = 0;
100 if (pref == 3) pref = 1;
102 if (pref == 1) pref = 0;
103 if (pref == 3) pref = 2;
105 if (res) bndy->Init (bndy->BoundaryType(),pref,bndy->Surface(),arc3d,sens,arcuv);
109 return Standard_False;
113 void IGESSelect_RemoveCurves::Performing (IFSelect_ContextModif& ctx,
114 const Handle(IGESData_IGESModel)& /*target*/,
115 Interface_CopyTool& /*TC*/) const
117 for (ctx.Start(); ctx.More(); ctx.Next()) {
118 if (Edit (ctx.ValueResult(),theUV) ) ctx.Trace ();
122 TCollection_AsciiString IGESSelect_RemoveCurves::Label () const
124 if (theUV) return TCollection_AsciiString ("Remove Curves UV on Face");
125 else return TCollection_AsciiString ("Remove Curves 3D on Face");