"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pariso/parametric/Model3D.cpp" between
mathmod-10.1-source.zip and mathmod-11.0-source.zip

About: MathMod is a mathematical modeling software that visualize and animate implicit and parametric surfaces.

Model3D.cpp  (mathmod-10.1-source):Model3D.cpp  (mathmod-11.0-source)
/*************************************************************************** /***************************************************************************
* Copyright (C) 2020 by Abderrahman Taha * * Copyright (C) 2021 by Abderrahman Taha *
* * * *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* This program is distributed in the hope that it will be useful, * * This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
skipping to change at line 1123 skipping to change at line 1123
void Par3D::CalculateColorsPoints(struct ComponentInfos *comp, uint index) void Par3D::CalculateColorsPoints(struct ComponentInfos *comp, uint index)
{ {
uint Iprime, Jprime,cmpId=0, K=0; uint Iprime, Jprime,cmpId=0, K=0;
double tmp, ValCol[masterthread->VRgbtSize], val[12]; double tmp, ValCol[masterthread->VRgbtSize], val[12];
val[11] = masterthread->stepMorph; val[11] = masterthread->stepMorph;
val[0] = val[1] = val[2] = 0.0; val[0] = val[1] = val[2] = 0.0;
if(comp->ThereisRGBA[index] == true && comp->NoiseParam[comp->ParisoCurrent ComponentIndex].NoiseType == 0) if(comp->ThereisRGBA[index] == true && comp->NoiseParam[comp->ParisoCurrent ComponentIndex].NoiseType == 0)
{ {
uint idx=0; uint idx=0;
for(uint i=0; i < comp->NbComponents.size()-1; i++) for(uint i=0; i < comp->NbComponentsType.size()-1; i++)
idx+=comp->NbComponents[i]; idx+=comp->NbComponentsType[i];
for(uint i= comp->ParisoVertex[2*idx]; i < NbVertexTmp; i++) for(uint i= comp->ParisoVertex[2*idx]; i < NbVertexTmp; i++)
{ {
if((i >= uint(comp->ParisoVertex[2*(cmpId+idx)]))) if((i >= uint(comp->ParisoVertex[2*(cmpId+idx)])))
{ {
K = cmpId; K = cmpId;
if((masterthread->componentsNumber -1)>cmpId) if((masterthread->componentsNumber -1)>cmpId)
{ {
cmpId++; cmpId++;
} }
} }
skipping to change at line 1208 skipping to change at line 1208
NormVertexTabVector[i*10+1] = float(ValCol[j+2]); NormVertexTabVector[i*10+1] = float(ValCol[j+2]);
NormVertexTabVector[i*10+2] = float(ValCol[j+3]); NormVertexTabVector[i*10+2] = float(ValCol[j+3]);
NormVertexTabVector[i*10+3] = float(ValCol[j+4]); NormVertexTabVector[i*10+3] = float(ValCol[j+4]);
j = masterthread->VRgbtSize; j = masterthread->VRgbtSize;
} }
} }
} }
else if(comp->ThereisRGBA[index] == true && comp->NoiseParam[comp->ParisoCu rrentComponentIndex].NoiseType == 1) else if(comp->ThereisRGBA[index] == true && comp->NoiseParam[comp->ParisoCu rrentComponentIndex].NoiseType == 1)
{ {
uint idx=0; uint idx=0;
for(uint i=0; i < comp->NbComponents.size()-1; i++) for(uint i=0; i < comp->NbComponentsType.size()-1; i++)
idx+=comp->NbComponents[i]; idx+=comp->NbComponentsType[i];
for(uint i= comp->ParisoVertex[2*idx]; i < NbVertexTmp; i++) for(uint i= comp->ParisoVertex[2*idx]; i < NbVertexTmp; i++)
{ {
if((i >= uint(comp->ParisoVertex[2*(cmpId+idx)]))) if((i >= uint(comp->ParisoVertex[2*(cmpId+idx)])))
{ {
K = cmpId; K = cmpId;
if((masterthread->componentsNumber -1)>cmpId) if((masterthread->componentsNumber -1)>cmpId)
{ {
cmpId++; cmpId++;
} }
} }
skipping to change at line 1272 skipping to change at line 1272
NormVertexTabVector[i*10 ] = float(masterthread->RgbtParser[0].Eval (val)); NormVertexTabVector[i*10 ] = float(masterthread->RgbtParser[0].Eval (val));
NormVertexTabVector[i*10+1] = float(masterthread->RgbtParser[1].Eval (val)); NormVertexTabVector[i*10+1] = float(masterthread->RgbtParser[1].Eval (val));
NormVertexTabVector[i*10+2] = float(masterthread->RgbtParser[2].Eval (val)); NormVertexTabVector[i*10+2] = float(masterthread->RgbtParser[2].Eval (val));
NormVertexTabVector[i*10+3] = float(masterthread->RgbtParser[3].Eval (val)); NormVertexTabVector[i*10+3] = float(masterthread->RgbtParser[3].Eval (val));
} }
} }
} }
uint Par3D::CNDCalculation(uint & NbTriangleIsoSurfaceTmp, struct ComponentInfos *comp) uint Par3D::CNDCalculation(uint & NbTriangleIsoSurfaceTmp, struct ComponentInfos *comp)
{ {
uint idmx=0; uint idmx=0;
for(uint i=0; i < comp->NbComponents.size()-1; i++) for(uint i=0; i < comp->NbComponentsType.size()-1; i++)
idmx+=comp->NbComponents[i]; idmx+=comp->NbComponentsType[i];
uint startpoint=comp->ParisoVertex[2*idmx]; uint startpoint=comp->ParisoVertex[2*idmx];
//In the case the isosurface part of a Pariso object doesn't have a CND cond ition //In the case the isosurface part of a Pariso object doesn't have a CND cond ition
int sz = (comp->ParisoCondition.size() == int sz = (comp->ParisoCondition.size() ==
comp->NbComponents[comp->NbComponents.size()-1]) ? 0 : idmx; comp->NbComponentsType[comp->NbComponentsType.size()-1]) ? 0 : idm x;
if (masterthread->ParisoCondition == 1) if (masterthread->ParisoCondition == 1)
{ {
double vals[4]; double vals[4];
std::vector<int> PointVerifyCond; std::vector<int> PointVerifyCond;
vals[3] = masterthread->stepMorph; vals[3] = masterthread->stepMorph;
for(uint i= startpoint; i < NbVertexTmp; i++) for(uint i= startpoint; i < NbVertexTmp; i++)
{ {
vals[0] = double(NormVertexTabVector[i*10+7]); vals[0] = double(NormVertexTabVector[i*10+7]);
vals[1] = double(NormVertexTabVector[i*10+8]); vals[1] = double(NormVertexTabVector[i*10+8]);
vals[2] = double(NormVertexTabVector[i*10+9]); vals[2] = double(NormVertexTabVector[i*10+9]);
skipping to change at line 1312 skipping to change at line 1312
{ {
NormVertexTabVector[i*10 ] = 0.9f; NormVertexTabVector[i*10 ] = 0.9f;
NormVertexTabVector[i*10+1] = 0.1f; NormVertexTabVector[i*10+1] = 0.1f;
NormVertexTabVector[i*10+2] = 0.9; NormVertexTabVector[i*10+2] = 0.9;
NormVertexTabVector[i*10+3] = 1.0; NormVertexTabVector[i*10+3] = 1.0;
} }
} }
uint Aindex, Bindex, Cindex; uint Aindex, Bindex, Cindex;
uint nbtriangle = NbTriangleIsoSurfaceTmp; uint nbtriangle = NbTriangleIsoSurfaceTmp;
uint idpx=0; uint idpx=0;
for(uint id=0; id < comp->NbComponents.size()-1; id++) for(uint id=0; id < comp->NbComponentsType.size()-1; id++)
idpx+=comp->NbComponents[id]; idpx+=comp->NbComponentsType[id];
uint starttri = uint(comp->ParisoTriangle[2*idpx]/3); uint starttri = uint(comp->ParisoTriangle[2*idpx]/3);
std::vector<int> TypeIsoSurfaceTriangleListeCNDVector (NbTriangleIsoSurf aceTmp-starttri, 1); std::vector<int> TypeIsoSurfaceTriangleListeCNDVector (NbTriangleIsoSurf aceTmp-starttri, 1);
for(uint i= starttri; i < nbtriangle; i++) for(uint i= starttri; i < nbtriangle; i++)
{ {
Aindex = IndexPolyTabVector[3*i ]; Aindex = IndexPolyTabVector[3*i ];
Bindex = IndexPolyTabVector[3*i + 1]; Bindex = IndexPolyTabVector[3*i + 1];
Cindex = IndexPolyTabVector[3*i + 2]; Cindex = IndexPolyTabVector[3*i + 2];
int TypeTriangle = -1; int TypeTriangle = -1;
if((PointVerifyCond[Aindex-startpoint] == 8) || if((PointVerifyCond[Aindex-startpoint] == 8) ||
(PointVerifyCond[Bindex-startpoint] == 8) || (PointVerifyCond[Bindex-startpoint] == 8) ||
skipping to change at line 1594 skipping to change at line 1594
} }
void Par3D::BuildPar() void Par3D::BuildPar()
{ {
ParamBuild( ParamBuild(
&(localScene->ArrayNorVer_localPt), &(localScene->ArrayNorVer_localPt),
&(localScene->PolyIndices_localPt), &(localScene->PolyIndices_localPt),
&localScene->PolyNumber, &localScene->PolyNumber,
&(localScene->VertxNumber), &(localScene->VertxNumber),
&(localScene->componentsinfos), &(localScene->componentsinfos),
&(localScene->PolyIndices_localPtMin), &(localScene->PolyIndices_localPtMin),
&(localScene->NbPolygnNbVertexPtMin) &(localScene->NbPolygnNbVertexPtMin),
&(localScene->NbPolygnNbVertexPtMinSize)
); );
} }
void Par3D::run() void Par3D::run()
{ {
BuildPar(); BuildPar();
} }
void Par3D::UpdateThredsNumber(uint NewThreadsNumber) void Par3D::UpdateThredsNumber(uint NewThreadsNumber)
{ {
uint tmp= WorkerThreadsNumber; uint tmp= WorkerThreadsNumber;
WorkerThreadsNumber = NewThreadsNumber; WorkerThreadsNumber = NewThreadsNumber;
skipping to change at line 1784 skipping to change at line 1785
void Par3D::emitErrorSignal() void Par3D::emitErrorSignal()
{ {
emit ErrorSignal(int(messageerror)); emit ErrorSignal(int(messageerror));
} }
void Par3D::copycomponent(struct ComponentInfos* copy, struct ComponentInfos* or igin) void Par3D::copycomponent(struct ComponentInfos* copy, struct ComponentInfos* or igin)
{ {
copy->ParisoTriangle = origin->ParisoTriangle; copy->ParisoTriangle = origin->ParisoTriangle;
copy->ParisoVertex = origin->ParisoVertex; copy->ParisoVertex = origin->ParisoVertex;
copy->NbComponents = origin->NbComponents; copy->NbComponentsType = origin->NbComponentsType;
copy->ParisoCurrentComponentIndex = origin->ParisoCurrentComponentIndex; copy->ParisoCurrentComponentIndex = origin->ParisoCurrentComponentIndex;
copy->ParisoNbComponents = origin->ParisoNbComponents; copy->ParisoNbComponents = origin->ParisoNbComponents;
copy->Interleave = origin->Interleave; copy->Interleave = origin->Interleave;
copy->pariso = origin->pariso; copy->pariso = origin->pariso;
copy->updateviewer = origin->updateviewer; copy->updateviewer = origin->updateviewer;
copy->ThereisCND = origin->ThereisCND; copy->ThereisCND = origin->ThereisCND;
copy->ParisoCondition = origin->ParisoCondition; copy->ParisoCondition = origin->ParisoCondition;
copy->ThereisRGBA = origin->ThereisRGBA; copy->ThereisRGBA = origin->ThereisRGBA;
copy->NbTrianglesVerifyCND = origin->NbTrianglesVerifyCND; copy->NbTrianglesVerifyCND = origin->NbTrianglesVerifyCND;
copy->NbTrianglesNoCND = origin->NbTrianglesNoCND; copy->NbTrianglesNoCND = origin->NbTrianglesNoCND;
skipping to change at line 1810 skipping to change at line 1811
} }
} }
void Par3D::ParamBuild( void Par3D::ParamBuild(
float **NormVertexTabPt, float **NormVertexTabPt,
uint **IndexPolyTabPt, uint **IndexPolyTabPt,
uint *PolyNumber, uint *PolyNumber,
uint *VertxNumber, uint *VertxNumber,
ComponentInfos *componentsPt, ComponentInfos *componentsPt,
uint **IndexPolyTabMinPt, uint **IndexPolyTabMinPt,
unsigned int *NbPolyMinPt unsigned int *NbPolyMinPt,
unsigned int *MinimPolySize
) )
{ {
uint NbTriangleIsoSurfaceTmp; uint NbTriangleIsoSurfaceTmp;
uint nbline_save=Ugrid, nbcolone_save=Vgrid, NextPosition=0; uint nbline_save=Ugrid, nbcolone_save=Vgrid, NextPosition=0;
NbVertexTmp = NbTriangleIsoSurfaceTmp = 0; NbVertexTmp = NbTriangleIsoSurfaceTmp = 0;
componentsPt->updateviewer= false; componentsPt->updateviewer= false;
clear(components); clear(components);
components->ParisoCondition = componentsPt->ParisoCondition; components->ParisoCondition = componentsPt->ParisoCondition;
if(componentsPt->pariso && componentsPt->ParisoCurrentComponentIndex>0) if(componentsPt->pariso && componentsPt->ParisoCurrentComponentIndex>0)
{ {
skipping to change at line 1842 skipping to change at line 1844
} }
NormVertexTabVector.clear(); NormVertexTabVector.clear();
NormVertexTabVector.shrink_to_fit(); NormVertexTabVector.shrink_to_fit();
IndexPolyTabVector.clear(); IndexPolyTabVector.clear();
IndexPolyTabVector.shrink_to_fit(); IndexPolyTabVector.shrink_to_fit();
IndexPolyTabMinVector.clear(); IndexPolyTabMinVector.clear();
IndexPolyTabMinVector.shrink_to_fit(); IndexPolyTabMinVector.shrink_to_fit();
} }
ExtraDimensionVector.clear(); ExtraDimensionVector.clear();
ExtraDimensionVector.shrink_to_fit(); ExtraDimensionVector.shrink_to_fit();
components->NbComponents.push_back(masterthread->componentsNumber); components->NbComponentsType.push_back(masterthread->componentsNumber);
stopcalculations(false); stopcalculations(false);
if(masterthread->activeMorph != 1) if(masterthread->activeMorph != 1)
{ {
ptime.restart(); ptime.restart();
} }
for(uint fctnb= 0; fctnb< masterthread->componentsNumber; fctnb++) for(uint fctnb= 0; fctnb< masterthread->componentsNumber; fctnb++)
{ {
if(masterthread->activeMorph != 1) if(masterthread->activeMorph != 1)
{ {
message = QString("1) Cmp:"+QString::number(fctnb+1)+"/"+QString::nu mber(masterthread->componentsNumber)+"==> Math calculation"); message = QString("1) Cmp:"+QString::number(fctnb+1)+"/"+QString::nu mber(masterthread->componentsNumber)+"==> Math calculation");
skipping to change at line 1952 skipping to change at line 1954
if(masterthread->activeMorph != 1) if(masterthread->activeMorph != 1)
{ {
message = QString("Threads:"+QString::number(WorkerThreadsNumber)+"; Cmp :"+QString::number(masterthread->componentsNumber)+"; T="+QString::number(ptime. elapsed()/1000.0)+"s"); message = QString("Threads:"+QString::number(WorkerThreadsNumber)+"; Cmp :"+QString::number(masterthread->componentsNumber)+"; T="+QString::number(ptime. elapsed()/1000.0)+"s");
emitUpdateMessageSignal(); emitUpdateMessageSignal();
} }
// 3) Nb Poly & Vertex : // 3) Nb Poly & Vertex :
{ {
*PolyNumber = uint(IndexPolyTabVector.size());//3*NbTriangleIsoSurf aceTmp; *PolyNumber = uint(IndexPolyTabVector.size());//3*NbTriangleIsoSurf aceTmp;
*VertxNumber = uint(NormVertexTabVector.size()/10);//NbVertexTmp; *VertxNumber = uint(NormVertexTabVector.size()/10);//NbVertexTmp;
*NbPolyMinPt = uint(IndexPolyTabMinVector.size());//NbPolyMinimalTop ology; *NbPolyMinPt = uint(IndexPolyTabMinVector.size());//NbPolyMinimalTop ology;
*IndexPolyTabMinPt = IndexPolyTabMinVector.data(); NormVertexTabVector.resize(NormVertexTabVector.size()+ (12+60+36)*10); /
/ To add memory space to store the cube 12 vertices (three quads)
uint startpl = 0;
uint actualpointindice=0;
for (uint i = 0; i < *NbPolyMinPt; i++)
{
uint polysize = IndexPolyTabMinVector[startpl++];
for (uint j = 0; j < polysize; j++)
{
actualpointindice = IndexPolyTabMinVector[startpl];
IndexPolyTabVector.push_back(actualpointindice);
startpl++;
}
i += polysize;
}
IndexPolyTabMinVector2.clear();
for (uint i = 0; i < *NbPolyMinPt; i++)
{
uint polysize = IndexPolyTabMinVector[i];
IndexPolyTabMinVector2.push_back(polysize);
i += polysize;
}
*MinimPolySize = IndexPolyTabVector.size() - *PolyNumber;
*NbPolyMinPt = uint(IndexPolyTabMinVector2.size());
*IndexPolyTabMinPt = IndexPolyTabMinVector2.data();
*NormVertexTabPt = NormVertexTabVector.data(); *NormVertexTabPt = NormVertexTabVector.data();
*IndexPolyTabPt = IndexPolyTabVector.data(); *IndexPolyTabPt = IndexPolyTabVector.data();
} }
copycomponent(componentsPt, components); copycomponent(componentsPt, components);
componentsPt->Interleave = true; componentsPt->Interleave = true;
if(componentsPt->ParisoCurrentComponentIndex != (componentsPt->ParisoNbCompo nents-1)) if(componentsPt->ParisoCurrentComponentIndex != (componentsPt->ParisoNbCompo nents-1))
componentsPt->ParisoCurrentComponentIndex += 1; componentsPt->ParisoCurrentComponentIndex += 1;
else else
componentsPt->ParisoCurrentComponentIndex = 0; componentsPt->ParisoCurrentComponentIndex = 0;
InitShowComponent(componentsPt);
componentsPt->updateviewer = true; componentsPt->updateviewer = true;
} }
void Par3D::InitShowComponent(struct ComponentInfos *cpInfos)
{
cpInfos->ShowParIsoCmp.clear();
for(uint i=0; i<cpInfos->NbComponentsType[cpInfos->NbComponentsType.size()-1
]; i++)
cpInfos->ShowParIsoCmp.push_back(true);
}
void Par3D::make_PolyIndexMin(uint index) void Par3D::make_PolyIndexMin(uint index)
{ {
uint k=0; uint k=0;
for (uint i=0; i+CutU+1 < Ugrid ; i++) for (uint i=0; i+CutU+1 < Ugrid ; i++)
for (uint j=0; j+CutV+1< Vgrid ; j++) for (uint j=0; j+CutV+1< Vgrid ; j++)
{ {
IndexPolyTabMinVector.push_back(4); IndexPolyTabMinVector.push_back(4);
IndexPolyTabMinVector.push_back(i*Vgrid + j+index); IndexPolyTabMinVector.push_back(i*Vgrid + j+index);
IndexPolyTabMinVector.push_back((i+1)*Vgrid + j +index); IndexPolyTabMinVector.push_back((i+1)*Vgrid + j +index);
IndexPolyTabMinVector.push_back((i+1)*Vgrid + (j+1)+index); IndexPolyTabMinVector.push_back((i+1)*Vgrid + (j+1)+index);
 End of changes. 13 change blocks. 
15 lines changed or deleted 52 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)