// File: GeoAlgo_Sol.cxx // Created: Mon Dec 15 16:32:27 1997 // Author: Cascade_Manager // #include "stdafx.h" #include "GeoAlgo_Sol.hxx" #include #include #include #include #include #include #include #include #include #include #include #include #include //============================================================================= // Empty constructor //============================================================================= GeoAlgo_Sol::GeoAlgo_Sol():myIsDone(Standard_False) { } //============================================================================= // Constructor with a file name //============================================================================= GeoAlgo_Sol::GeoAlgo_Sol(const Standard_CString aGroundName) { myGround = Read(aGroundName); // if an error occurs in the construction the method IsDone // returns False. } //============================================================================= // Build(File) // Build method from an empty object //============================================================================= void GeoAlgo_Sol::Build(const Standard_CString aGroundName) { myGround = Read(aGroundName); // if an error occurs in the construction the method IsDone // returns False. } //============================================================================= // Build(Sequence of Points) // Build method from an empty object // Called also from the Builde method from a file //============================================================================= void GeoAlgo_Sol::Build(const TColgp_SequenceOfXYZ& seqOfXYZ) { // Build the surface: // points are projected on plane z = 0 // the projection vector for each point is computed // These data give the input constraints loaded into plate algorithm myIsDone = Standard_True; Standard_Integer nbPnt = seqOfXYZ.Length(); Standard_Integer i; //Filling plate Plate_Plate myPlate; std::cout<<" * Number of points = "<< nbPnt << std::endl; for (i=1; i<= nbPnt; i++) { gp_Pnt ptProj(seqOfXYZ.Value(i).X(), seqOfXYZ.Value(i).Y(), 0. ); gp_Vec aVec( ptProj, seqOfXYZ.Value(i)); gp_XY pntXY(seqOfXYZ.Value(i).X(),seqOfXYZ.Value(i).Y()); Plate_PinpointConstraint PCst( pntXY,aVec.XYZ() ); myPlate.Load(PCst);// Load plate } myPlate.SolveTI(2, 1.);// resolution if (!myPlate.IsDone()) { std::cout<<" plate computation has failed"<< std::endl; myIsDone=Standard_False; } // Computation of plate surface gp_Pnt Or(0,0,0.); gp_Dir Norm(0., 0., 1.); Handle(Geom_Plane) myPlane = new Geom_Plane(Or, Norm);// Plane of normal Oz Handle(GeomPlate_Surface) myPlateSurf = new GeomPlate_Surface( myPlane, myPlate);//plate surface GeomPlate_MakeApprox aMKS(myPlateSurf, Precision::Approximation(), 4, 7, 0.001, 0);//bspline surface myGround = aMKS.Surface(); // if an error occurs in the construction the method IsDone // returns False. } //============================================================================= // Surface() // Returns the resulting surface as a bspline surface //============================================================================= Handle(Geom_BSplineSurface) GeoAlgo_Sol::Surface() const { return myGround; } //============================================================================ // IsDone() // Checks the construction of the surface //============================================================================ Standard_Boolean GeoAlgo_Sol::IsDone() const { // Returns True if the construction successes, False otherwise return myIsDone; } //============================================================================= // Read(File) // Private method called from constructor //============================================================================= Handle(Geom_BSplineSurface) GeoAlgo_Sol::Read(const Standard_CString aGroundName) { // This methods read a file of points ans build a surface using plate algorithm myIsDone = Standard_True; Standard_Integer nbPnt=0; // Read points from the file std::filebuf fic; std::istream in(&fic); if (!fic.open(aGroundName,std::ios::in)){ std::cout << " impossible to open a file : "<> x && in >> y && in >> z){ pntXYZ.SetX(x); pntXYZ.SetY(y); pntXYZ.SetZ(z); nbPnt++; seqOfXYZ.Append(pntXYZ); } } fic.close(); Build(seqOfXYZ); return myGround; }