1 // Created on: 1998-06-04
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and / or modify it
9 // under the terms of the GNU Lesser General Public version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TopOpeBRepDS_TKI.hxx>
18 #include <TopOpeBRepDS_HDataStructure.hxx>
20 #include <TopOpeBRep_define.hxx>
22 typedef TopOpeBRepDS_ListOfInterference* BOA_t;
24 static int compll(const void* v1, const void* v2) {
25 BOA_t l1 = *(BOA_t*)v1;
26 BOA_t l2 = *(BOA_t*)v2;
27 if (l1->Extent() == 0) return (0);
28 else if (l2->Extent() == 0) return (0);
30 Handle(TopOpeBRepDS_CurvePointInterference) i1 = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(l1->First());
33 Handle(TopOpeBRepDS_CurvePointInterference) i2 = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(l2->First());
36 Standard_Real p1 = i1->Parameter();
37 Standard_Real p2 = i2->Parameter();
38 if (p1 < p2) return (-1);
39 else if (p1 > p2) return (1);
43 static void BREP_sortonparameter2(TopOpeBRepDS_ListOfInterference& LOI)
46 tki.FillOnGeometry(LOI);
47 Standard_Integer ng=0;
48 for(tki.Init();tki.More();tki.Next())
50 size_t sng=(size_t)ng;
51 size_t sad=sizeof(BOA_t);
52 BOA_t* T = (BOA_t*)Standard::Allocate (sng*sad);
54 Standard_Integer G, j=0;
55 for(tki.Init();tki.More();tki.Next(),j++)
56 T[j]= &(tki.ChangeValue(K,G));
57 qsort(T,sng,sad,compll);
61 TopOpeBRepDS_ListOfInterference& l=*T[j];
67 Standard_EXPORT void BREP_sortonparameter(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
69 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
70 Standard_Integer i=1, n=HDS->NbShapes();
72 const TopoDS_Shape& s = HDS->Shape(i);
73 if (s.ShapeType() != TopAbs_EDGE) continue;
74 TopOpeBRepDS_ListOfInterference& LOI = BDS.ChangeShapeInterferences(s);
75 BREP_sortonparameter2(LOI);