// Created on: 1997-04-15
// Created by: Joelle CHAUVET
// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
#include <GeomliteTest.hxx>
#include <DrawTrSurf.hxx>
#include <Precision.hxx>
#include <GeomLib.hxx>
-#ifdef WNT
+#include <Geom2d_BezierCurve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <Geom_BezierCurve.hxx>
+#include <Geom_BezierSurface.hxx>
+#include <Geom_BSplineCurve.hxx>
+#include <Geom_BSplineSurface.hxx>
+#include <Geom_BoundedCurve.hxx>
+#include <Geom_BoundedSurface.hxx>
+
+#ifdef _MSC_VER
#include <stdio.h>
//#define strcasecmp strcmp Already defined
#endif
//purpose :
//=======================================================================
-static Standard_Integer samerange (Draw_Interpretor& di, Standard_Integer n, const char** a)
+static Standard_Integer samerange (Draw_Interpretor& /*di*/, Standard_Integer n, const char** a)
{
if (n < 6) return 1;
Handle(Geom2d_Curve) C = DrawTrSurf::GetCurve2d(a[2]);
}
//=======================================================================
+//function : setweight
+//purpose : Changes a weight of a pole on B-spline curve/surface
+//=======================================================================
+
+static Standard_Integer setweight(Draw_Interpretor& /*di*/, Standard_Integer n, const char** a)
+{
+ if (n < 4 || n > 5)
+ {
+ std::cout << "Wrong parameters" << std::endl;
+ return 1;
+ }
+
+ Standard_Integer anIndex1 = Draw::Atoi(a[2]);
+ Standard_Integer anIndex2 = n == 5 ? Draw::Atoi(a[3]) : 0;
+ Standard_Real aWeight = Draw::Atof(a[n-1]);
+
+ Handle(Geom_BSplineCurve) aBSplCurve = DrawTrSurf::GetBSplineCurve(a[1]);
+ if (!aBSplCurve.IsNull())
+ {
+ aBSplCurve->SetWeight(anIndex1, aWeight);
+ return 0;
+ }
+
+ Handle(Geom_BezierCurve) aBezCurve = DrawTrSurf::GetBezierCurve(a[1]);
+ if (!aBezCurve.IsNull())
+ {
+ aBezCurve->SetWeight(anIndex1, aWeight);
+ return 0;
+ }
+
+ Handle(Geom2d_BSplineCurve) aBSplCurve2d = DrawTrSurf::GetBSplineCurve2d(a[1]);
+ if (!aBSplCurve2d.IsNull())
+ {
+ aBSplCurve2d->SetWeight(anIndex1, aWeight);
+ return 0;
+ }
+
+ Handle(Geom2d_BezierCurve) aBezCurve2d = DrawTrSurf::GetBezierCurve2d(a[1]);
+ if (!aBezCurve2d.IsNull())
+ {
+ aBezCurve2d->SetWeight(anIndex1, aWeight);
+ return 0;
+ }
+
+ Handle(Geom_BSplineSurface) aBSplSurf = DrawTrSurf::GetBSplineSurface(a[1]);
+ Handle(Geom_BezierSurface) aBezSurf = DrawTrSurf::GetBezierSurface(a[1]);
+ if (n != 5 && (!aBSplSurf.IsNull() || !aBezSurf.IsNull()))
+ {
+ std::cout << "Incorrect parameters" << std::endl;
+ return 1;
+ }
+
+ if (!aBSplSurf.IsNull())
+ {
+ aBSplSurf->SetWeight(anIndex1, anIndex2, aWeight);
+ return 0;
+ }
+
+ if (!aBezSurf.IsNull())
+ {
+ aBezSurf->SetWeight(anIndex1, anIndex2, aWeight);
+ return 0;
+ }
+
+ std::cout << a[1] << " is not a B-spline nor a Bezier curve/surface" << std::endl;
+ return 1;
+}
+
+//=======================================================================
//function : ModificationCommands
//purpose :
//=======================================================================
__FILE__,
samerange, g);
+ theCommands.Add("setweight",
+ "setweight curve/surf index1 [index2] weight"
+ "\n\t\tchanges a weight of a pole of B-spline curve/surface (index2 is useful for surfaces only)",
+ __FILE__,
+ setweight,g);
+
}