// Created on: 2004-06-15 // Created by: Sergey ZARITCHNY // Copyright (c) 2004-2012 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. // // 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. // // 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. #include #include #include #include #include #include //======================================================================= //function : operator >> (gp_Trsf& T) //purpose : //======================================================================= static Standard_IStream& operator >>(Standard_IStream& IS, gp_Trsf& T) { Standard_Real V1[3],V2[3],V3[3]; Standard_Real V[3]; BinTools::GetReal(IS, V1[0]); BinTools::GetReal(IS, V1[1]); BinTools::GetReal(IS, V1[2]); BinTools::GetReal(IS, V[0]); BinTools::GetReal(IS, V2[0]); BinTools::GetReal(IS, V2[1]); BinTools::GetReal(IS, V2[2]); BinTools::GetReal(IS, V[1]); BinTools::GetReal(IS, V3[0]); BinTools::GetReal(IS, V3[1]); BinTools::GetReal(IS, V3[2]); BinTools::GetReal(IS, V[2]); T.SetValues(V1[0],V1[1],V1[2],V[0], V2[0],V2[1],V2[2],V[1], V3[0],V3[1],V3[2],V[2], Precision::Angular(), Precision::Confusion()); return IS; } //======================================================================= //function : operator << (gp_Trsf& T) //purpose : //======================================================================= static Standard_OStream& operator <<(Standard_OStream& OS,const gp_Trsf& T) { gp_XYZ V = T.TranslationPart(); gp_Mat M = T.VectorialPart(); BinTools::PutReal(OS, M(1,1)); BinTools::PutReal(OS, M(1,2)); BinTools::PutReal(OS, M(1,3)); BinTools::PutReal(OS,V.Coord(1)); BinTools::PutReal(OS, M(2,1)); BinTools::PutReal(OS, M(2,2)); BinTools::PutReal(OS, M(2,3)); BinTools::PutReal(OS,V.Coord(2)); BinTools::PutReal(OS, M(3,1)); BinTools::PutReal(OS, M(3,2)); BinTools::PutReal(OS, M(3,3)); BinTools::PutReal(OS,V.Coord(3)); return OS; } //======================================================================= //function : BinTools_LocationSet //purpose : //======================================================================= BinTools_LocationSet::BinTools_LocationSet() { } //======================================================================= //function : Clear //purpose : //======================================================================= void BinTools_LocationSet::Clear() { myMap.Clear(); } //======================================================================= //function : Add //purpose : //======================================================================= Standard_Integer BinTools_LocationSet::Add(const TopLoc_Location& L) { if (L.IsIdentity()) return 0; Standard_Integer n = myMap.FindIndex(L); if (n > 0) return n; TopLoc_Location N = L; do { myMap.Add(N.FirstDatum()); N = N.NextLocation(); } while (!N.IsIdentity()); return myMap.Add(L); } //======================================================================= //function : Location //purpose : //======================================================================= const TopLoc_Location& BinTools_LocationSet::Location (const Standard_Integer I)const { static TopLoc_Location identity; if (I == 0) return identity; else return myMap(I); } //======================================================================= //function : Index //purpose : //======================================================================= Standard_Integer BinTools_LocationSet::Index(const TopLoc_Location& L) const { if (L.IsIdentity()) return 0; return myMap.FindIndex(L); } //======================================================================= //function : NbLocations //purpose : //======================================================================= Standard_Integer BinTools_LocationSet::NbLocations() const { return myMap.Extent(); } //======================================================================= //function : Write locations //purpose : //======================================================================= void BinTools_LocationSet::Write(Standard_OStream& OS) const { Standard_Integer i, nbLoc = myMap.Extent(); OS << "Locations "<< nbLoc <> buffer; if (IS.fail() || (strcmp(buffer,"Locations"))) { Standard_SStream aMsg; aMsg << "BinTools_LocationSet::Read: Not a location table"<> nbLoc; IS.get();// remove lf TopLoc_Location L; gp_Trsf T; try { OCC_CATCH_SIGNALS for (i = 1; i <= nbLoc; i++) { const Standard_Byte aTypLoc = IS.get(); if (aTypLoc == 1) { IS >> T; L = T; } else if (aTypLoc == 2) { L = TopLoc_Location(); BinTools::GetInteger(IS, l1); //Index while (l1 != 0) { BinTools::GetInteger(IS, p); TopLoc_Location L1 = myMap(l1); L = L1.Powered(p) *L; BinTools::GetInteger(IS, l1); } } else { Standard_SStream aMsg; aMsg << "Unexpected location's type = " << aTypLoc << endl; Standard_Failure::Raise(aMsg); } if (!L.IsIdentity()) myMap.Add(L); } } catch(Standard_Failure) { Standard_SStream aMsg; aMsg << "EXCEPTION in BinTools_LocationSet::Read(..)" << endl; Handle(Standard_Failure) anExc = Standard_Failure::Caught(); aMsg << anExc << endl; Standard_Failure::Raise(aMsg); } }