10 #include <TVirtualGeoPainter.h>
11 #include <TVirtualViewer3D.h>
12 #include <TBuffer3D.h>
13 #include <TBuffer3DTypes.h>
14 #include <TGeoBoolNode.h>
15 #include <TGeoManager.h>
19 #include <Bnd_Box.hxx>
20 #include <BRepBndLib.hxx>
21 #include <BRepMesh_IncrementalMesh.hxx>
23 #include <StlAPI_Writer.hxx>
28 typedef std::map<const EicStlKey*, unsigned, bool(*)(const EicStlKey*, const EicStlKey*)> qEntry;
55 snprintf(buffer, 128-1,
"./%05d-tmp.stl", getpid());
60 BRepMesh_IncrementalMesh(*
mSolid, stl_quality_coefficient);
62 writer.ASCIIMode() =
false;
63 writer.Write(*
mSolid, buffer);
100 unsigned vCounter = 0, eCounter = 0, fCounter = 0;
102 for(fEntry::const_iterator ft=mgroup->
facets()->begin(); ft!=mgroup->
facets()->end(); ft++) {
106 lb->
fPols[3*fCounter+0] = eCounter+0;
107 lb->
fPols[3*fCounter+1] = eCounter+1;
108 lb->
fPols[3*fCounter+2] = eCounter+2;
112 lb->
fSegs[2*eCounter+0] = vCounter+0;
113 lb->
fSegs[2*eCounter+1] = vCounter+1;
115 lb->
fSegs[2*eCounter+0] = vCounter+1;
116 lb->
fSegs[2*eCounter+1] = vCounter+2;
118 lb->
fSegs[2*eCounter+0] = vCounter+2;
119 lb->
fSegs[2*eCounter+1] = vCounter+0;
123 for(
unsigned vt=0; vt<3; vt++) {
127 for(
unsigned iq=0; iq<3; iq++)
128 lb->
fPnts[vCounter*3 + iq] = arr[iq];
147 lb->
fNbSegs = assembly->facets().size() * 3 / 2;
148 lb->
fNbPols = assembly->facets().size();
164 unsigned eCounter = 0, vCounter = 0;
168 for(
unsigned fc=0; fc<assembly->facets().size(); fc++) {
170 bool orientation = assembly->facets()[fc].second;
172 for(
unsigned ee=0; ee<3; ee++) {
175 if (edgeKeys.find(edge->
key()) == edgeKeys.end()) {
177 unsigned evCounter = 0;
178 for(vEntry::const_iterator vt=edge->
vertices()->begin(); vt!=edge->
vertices()->end() ; vt++) {
181 if (vtxKeys.find(vertex->
key()) == vtxKeys.end()) {
185 for(
unsigned iq=0; iq<3; iq++)
186 lb->
fPnts[vCounter*3 + iq] = arr[iq];
188 vtxKeys[vertex->
key()] = vCounter++;
192 lb->
fSegs[eCounter*2 + evCounter++] = vtxKeys[vertex->
key()];
195 edgeKeys[edge->
key()] = eCounter++;
199 lb->
fPols[fc*3 + (orientation ? 2-ee : ee)] = edgeKeys[edge->
key()];
226 for(
unsigned pt=0; pt<lb->
fNbPnts; pt++)
227 for(
unsigned iq=0; iq<3; iq++)
228 points[pt*3+iq] = lb->
fPnts[pt*3+iq];
236 Int_t
c = GetBasicColor();
241 for(
unsigned sg=0; sg<lb->
fNbSegs; sg++) {
244 for(
unsigned iq=0; iq<2; iq++)
245 buff.fSegs[sg*3+iq+1] = lb->
fSegs[sg*2+iq];
248 for(
unsigned fc=0; fc<lb->
fNbPols; fc++) {
249 buff.fPols[fc*5+0] =
c;
250 buff.fPols[fc*5+1] = 3;
253 for(
unsigned iq=0; iq<3; iq++)
254 buff.fPols[fc*5+iq+2] = lb->
fPols[fc*3+2-iq];
268 TGeoShape::FillBuffer3D(buffer, reqSections, localFrame);
277 double halfLengths[3] = {
282 if (reqSections & TBuffer3D::kBoundingBox) {
283 buffer.SetAABoundingBox(origin, halfLengths);
285 if (!buffer.fLocalFrame) {
286 TransformPoints(buffer.fBBVertex[0], 8);
289 buffer.SetSectionsValid(TBuffer3D::kBoundingBox);
300 static TBuffer3D
buffer(TBuffer3DTypes::kGeneric);
309 if (reqSections & TBuffer3D::kRawSizes) {
313 buffer.SetSectionsValid(TBuffer3D::kRawSizes);
316 if ((reqSections & TBuffer3D::kRaw) && buffer.SectionsValid(TBuffer3D::kRawSizes)) {
318 if (!buffer.fLocalFrame) {
319 TransformPoints(buffer.fPnts, buffer.NbPnts());
323 buffer.SetSectionsValid(TBuffer3D::kRaw);
336 Bool_t addChildren = kTRUE;
338 TVirtualGeoPainter *painter = gGeoManager->GetGeomPainter();
339 TVirtualViewer3D *
viewer = gPad->GetViewer3D();
340 if (!painter || !viewer)
return kFALSE;
343 Bool_t localFrame = viewer->PreferLocalFrame();
346 const TBuffer3D & buffer =
347 GetBuffer3D(TBuffer3D::kCore|TBuffer3D::kBoundingBox, localFrame);
348 Int_t reqSections = viewer->AddObject(buffer, &addChildren);
352 if (reqSections != TBuffer3D::kNone) {
354 viewer->AddObject(buffer, &addChildren);