53 std::unique_ptr<RootCsg::TBaseMesh> res;
61 for (
UInt_t i = 0; i < b3d->NbPnts(); ++i) {
69 res.reset(RootCsg::ConvertToMesh(*b3d.get()));
74 if (matr) { mleft = *matr; mright = *matr; }
76 mleft.
Multiply(node->GetLeftMatrix());
77 auto left =
MakeGeoMesh(&mleft, node->GetLeftShape());
79 mright.
Multiply(node->GetRightMatrix());
80 auto right =
MakeGeoMesh(&mright, node->GetRightShape());
82 if (node->IsA() ==
TGeoUnion::Class()) res.reset(RootCsg::BuildUnion(left.get(), right.get()));
106 Int_t nv = mesh->NumberOfVertices();
109 for (
Int_t i = 0; i < nv; ++i) {
110 auto v = mesh->GetVertex(i);
114 fNbPols = mesh->NumberOfPolys();
118 for (
Int_t i = 0; i <
fNbPols; ++i) descSize += mesh->SizeOfPoly(i) + 1;
122 for (
Int_t polyIndex = 0; polyIndex <
fNbPols; ++polyIndex) {
123 Int_t polySize = mesh->SizeOfPoly(polyIndex);
127 for (
Int_t i = 0; i < polySize; ++i)
128 fPolyDesc.push_back(mesh->GetVertexIndex(polyIndex, i));
203 descSize += pols[j] + 1;
209 for (
Int_t numPol = 0, currInd = 0, j = 1; numPol <
fNbPols; ++numPol)
211 Int_t segmentInd = pols[j] + j;
212 Int_t segmentCol = pols[j];
215 Int_t s2 = pols[segmentInd];
218 segs[s2 * 3 + 1],
segs[s2 * 3 + 2]};
221 if (segEnds[0] == segEnds[2]) {
222 numPnts[0] = segEnds[1]; numPnts[1] = segEnds[0]; numPnts[2] = segEnds[3];
223 }
else if (segEnds[0] == segEnds[3]) {
224 numPnts[0] = segEnds[1]; numPnts[1] = segEnds[0]; numPnts[2] = segEnds[2];
225 }
else if (segEnds[1] == segEnds[2]) {
226 numPnts[0] = segEnds[0]; numPnts[1] = segEnds[1]; numPnts[2] = segEnds[3];
228 numPnts[0] = segEnds[0]; numPnts[1] = segEnds[1]; numPnts[2] = segEnds[2];
232 Int_t sizeInd = currInd++;
236 Int_t lastAdded = numPnts[2];
239 for (; segmentInd != end; segmentInd--) {
240 segEnds[0] =
segs[pols[segmentInd] * 3 + 1];
241 segEnds[1] =
segs[pols[segmentInd] * 3 + 2];
242 if (segEnds[0] == lastAdded) {
244 lastAdded = segEnds[1];
247 lastAdded = segEnds[0];
292 pnts + norm[2] * 3, &
fNormals[i * 3]);
303 pnts + norm[2] * 3, &
fNormals[i * 3]);
328 }
else if (
Eq(p1, p3)) {
353 return (dx < 1
e-10) && (dy < 1
e-10) && (dz < 1
e-10);
364 b.ClearSectionsValid();
380 std::map<Edge_t, Int_t> edges;
386 for (
Int_t j = 0; j < nv; ++j) {
387 Edge_t e(pd[j], (j != nv - 1) ? pd[j + 1] : pd[0]);
388 if (edges.find(
e) == edges.end()) {
389 edges.insert(std::make_pair(
e, 0));
400 Int_t si = 0, scnt = 0;
401 for (
auto &edge : edges) {
403 b.fSegs[si++] = edge.first.fI;
404 b.fSegs[si++] = edge.first.fJ;
405 edge.second = scnt++;
415 for (
Int_t j = 0; j < nv; ++j) {
416 b.fPols[
pi++] = edges[
Edge_t(pd[j], (j != nv - 1) ? pd[j + 1] : pd[0])];
std::unique_ptr< RootCsg::TBaseMesh > MakeGeoMesh(TGeoMatrix *matr, TGeoShape *shape)
Function produces mesh for provided shape, applying matrix to the result.
void ProcessData(const std::vector< Double_t > &verts, const std::vector< Int_t > &polys, const Int_t n_polys)
ProcessData.
std::vector< Int_t > & RefPolyDesc()
REveGeoManagerHolder Exception-safe global variable holders.
void FillRenderData(REveRenderData &rd)
std::vector< Int_t > fPolyDesc
static Bool_t fgAutoCalculateNormals
static void SetAutoEnforceTriangles(Bool_t f)
virtual void FillBuffer3D(TBuffer3D &buffer, Int_t reqSections, Bool_t localFrame) const
Fill the passed buffer 3D.
static void SetAutoCalculateNormals(Bool_t f)
void EnforceTriangles()
Use GLU tesselator to replace all polygons with N > 3 with triangles.
Int_t CheckPoints(const Int_t *source, Int_t *dest) const
CheckPoints.
void BuildFromShape(TGeoShape *shape, Int_t n_seg=60)
Produce all polygons from normal shape.
void BuildFromComposite(TGeoCompositeShape *cshp, Int_t n_seg=60)
Produce all polygons from composite shape.
std::vector< Double_t > fNormals
virtual TBuffer3D * MakeBuffer3D() const
Create buffer 3D and fill it with point/segment/poly data.
std::vector< Double_t > fVertices
static Bool_t GetAutoCalculateNormals()
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Fill static buffer 3D.
void CalculateNormals()
CalculateNormals per polygon (flat shading)
static Bool_t GetAutoEnforceTriangles()
static Bool_t fgAutoEnforceTriangles
void SetFromBuff3D(const TBuffer3D &buffer)
Set data-members from a Csg mesh.
static Bool_t Eq(const Double_t *p1, const Double_t *p2)
Test equality of points with epsilon 1e-10.
static TGeoManager * GetGeoManager()
Return static geo-manager that is used internally to make shapes lead a happy life.
void Reserve(int size_vert=0, int size_norm=0, int size_idx=0)
Reserve place for render data.
Generic 3D primitive description class.
virtual const Double_t * GetOrigin() const
virtual Double_t GetDX() const
virtual Double_t GetDZ() const
virtual Double_t GetDY() const
Class handling Boolean composition of shapes.
TGeoBoolNode * GetBoolNode() const
Matrix class used for computing global transformations Should NOT be used for node definition.
void Multiply(const TGeoMatrix *right)
multiply to the right with an other transformation if right is identity matrix, just return
Geometrical transformation package.
virtual void LocalToMaster(const Double_t *local, Double_t *master) const
convert a point by multiplying its column vector (x, y, z, 1) to matrix inverse
Base abstract class for all shapes.
virtual TBuffer3D * MakeBuffer3D() const
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
static constexpr double pi
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
Calculate a normal vector of a plane.
#define dest(otri, vertexptr)