Esempio n. 1
0
void SoVtkFieldData::inputChanged(SoField * f)
{
    // Get the Component value
    if ( f == &Component )
    {
        SbVariant *vComponent = (SbVariant *)Component.getValues(0);
        SoInput input;
        int nb_fields = Component.getNum();

        vtkIdType val0;
        int val1;
        double val2;
        for (int i=0; i < nb_fields; i++)
        {
            input.setBuffer((void *)vComponent[i].getField().getString(),256);
            input.read(val0);
            input.read(val1);
            input.read(val2);
            mObject->SetComponent(
                (const vtkIdType) val0,
                (const int) val1,
                (const double) val2
            );
        }
    }

}
void SoVtkOutlineFilter::inputChanged(SoField * f)
{
	// Get the InputArrayToProcess value
	if ( f == &InputArrayToProcess )
	{
		SbVariant vInputArrayToProcess = (SbVariant)InputArrayToProcess.getValue();
		SoInput input;
		int val0;
		int val1;
		int val2;
		int val3;
		SbString val4;
	
		input.setBuffer((void *)vInputArrayToProcess.getField().getString(),256);
		input.read(val0);
		input.read(val1);
		input.read(val2);
		input.read(val3);
		input.read(val4);
		mObject->SetInputArrayToProcess( 
			(int) val0,
			(int) val1,
			(int) val2,
			(int) val3,
			val4.getString()
		);
	}
	//mObject->Update();
	
}
Esempio n. 3
0
void
DragDropHandlerP::dropEvent(QDropEvent * event)
{
  const QMimeData * mimedata = event->mimeData();

  SoSeparator * root;
  SoInput in;
  QByteArray bytes;

  if (mimedata->hasUrls()) {
    QUrl url = mimedata->urls().takeFirst();
    if (url.scheme().isEmpty() || url.scheme().toLower() == QString("file") ) {
      // attempt to open file
      if (!in.openFile(url.toLocalFile().toLatin1().constData())) return;
    }
  } else if (mimedata->hasText()) {
    /* FIXME 2007-11-09 preng: dropping text buffer does not work on Windows Vista. */
    bytes = mimedata->text().toUtf8();
    in.setBuffer((void *) bytes.constData(), bytes.size());
    if (!in.isValidBuffer()) return;
  }

  // attempt to import it
  root = SoDB::readAll(&in);
  if (root == NULL) return;

  // set new scenegraph
  this->quarterwidget->setSceneGraph(root);
  this->quarterwidget->viewport()->update();
}
void SoVtkImageVariance3D::inputChanged(SoField * f)
{
	// Get the KernelSize value
	if ( f == &KernelSize )
	{
		SbVariant *vKernelSize = (SbVariant *)KernelSize.getValues(0);
		SoInput input;
		int nb_fields = KernelSize.getNum();

		int val0;
		int val1;
		int val2;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vKernelSize[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			input.read(val2);
			mObject->SetKernelSize( 
				(int) val0,
				(int) val1,
				(int) val2
			);
		}
	}

	// Get the NumberOfThreads value
	if ( f == &NumberOfThreads )
		SO_VTK_SET_FIELD_VALUE( mObject, NumberOfThreads);

	mObject->Update();
}
void SoVtkGenericProbeFilter::inputChanged(SoField * f)
{
	// Get the Source value
	if ( f == &Source )
		SO_VTK_SET_FIELD_DATA( mObject, Source, vtkGenericDataSet);

	// Get the NumberOfInputConnections value
	if ( f == &NumberOfInputConnections )
	{
		SbVariant *vNumberOfInputConnections = (SbVariant *)NumberOfInputConnections.getValues(0);
		SoInput input;
		int nb_fields = NumberOfInputConnections.getNum();

		int val0;
		int val1;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vNumberOfInputConnections[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			//mObject->SetNumberOfInputConnections( (int) val0, (int) val1 );
		}
	}

	mObject->Update();
}
void LightManip(SoSeparator * root)
{

  SoInput in;
  in.setBuffer((void *)scenegraph, std::strlen(scenegraph));
  SoSeparator * _root = SoDB::readAll( &in );
  if ( _root == NULL ) return; // Shouldn't happen.
  root->addChild(_root);
  root->ref();

  const char * pointlightnames[3] = { "RedLight", "GreenLight", "BlueLight" };
  SoSearchAction sa;

  for (int i = 0; i < 3; i++) {
    sa.setName( pointlightnames[i] );
    sa.setInterest( SoSearchAction::FIRST );
    sa.setSearchingAll( false );
    sa.apply( root );
    SoPath * path = sa.getPath();
    if ( path == NULL) return; // Shouldn't happen.

    SoPointLightManip * manip = new SoPointLightManip;
    manip->replaceNode( path );
  }


} 
Esempio n. 7
0
void SoVtkFieldData::reset()
{
    mObject->UnRegister(0);
    mObject->Delete();
    mObject = 0;
    mObject = vtkFieldData::New();
    mObject->Register(0);
    mObject->SetGlobalWarningDisplay(0);
    // Get the input type(s)
    // Get the Component value
    if (addCalled == 1)
    {
        SbVariant *vComponent = (SbVariant *)Component.getValues(0);
        SoInput input;
        int nb_fields = Component.getNum();

        vtkIdType val0;
        int val1;
        double val2;
        for (int i=0; i < nb_fields; i++)
        {
            input.setBuffer((void *)vComponent[i].getField().getString(),256);
            input.read(val0);
            input.read(val1);
            input.read(val2);
            mObject->SetComponent(
                (const vtkIdType) val0,
                (const int) val1,
                (const double) val2
            );
        }
    }

}
Esempio n. 8
0
void SoVtkConeSource::inputChanged(SoField * f)
{
	// Get the Radius value
	if ( f == &Radius )
		SO_VTK_SET_FIELD_VALUE( mObject, Radius);

	// Get the Height value
	if ( f == &Height )
		SO_VTK_SET_FIELD_VALUE( mObject, Height);

	// Get the Capping value
	if ( f == &Capping )
		SO_VTK_SET_FIELD_VALUE( mObject, Capping);

	// Get the Direction value
	if ( f == &Direction )
		SO_VTK_SET_FIELD_VEC3F( mObject, Direction);

	// Get the Center value
	if ( f == &Center )
		SO_VTK_SET_FIELD_VEC3F( mObject, Center);

	// Get the Resolution value
	if ( f == &Resolution )
		SO_VTK_SET_FIELD_VALUE( mObject, Resolution);

	// Get the Angle value
	if ( f == &Angle )
		SO_VTK_SET_FIELD_VALUE( mObject, Angle);

	// Get the InputArrayToProcess value
	if ( f == &InputArrayToProcess )
	{
		SbVariant vInputArrayToProcess = (SbVariant)InputArrayToProcess.getValue();
		SoInput input;
		int val0;
		int val1;
		int val2;
		int val3;
		SbString val4;
	
		input.setBuffer((void *)vInputArrayToProcess.getField().getString(),256);
		input.read(val0);
		input.read(val1);
		input.read(val2);
		input.read(val3);
		input.read(val4);
		mObject->SetInputArrayToProcess( 
			(int) val0,
			(int) val1,
			(int) val2,
			(int) val3,
			val4.getString()
		);
	}
	//mObject->Update();
	
}
void SoVtkImageWrapPad::reset()
{
	mObject->UnRegister(0);
	mObject->Delete();
	mObject = 0;
	mObject = vtkImageWrapPad::New();
	mObject->Register(0);
	mObject->SetGlobalWarningDisplay(0);
	// Get the input type(s)
	SoVtkAlgorithmOutput *inputPortPtr = InputConnection.getValue();
	
	if (inputPortPtr)
		mObject->SetInputConnection(inputPortPtr->getPointer());

	// Get the OutputNumberOfScalarComponents value
	
		SO_VTK_SET_FIELD_VALUE( mObject, OutputNumberOfScalarComponents);

	// Get the NumberOfThreads value
	
		SO_VTK_SET_FIELD_VALUE( mObject, NumberOfThreads);

	// Get the OutputWholeExtent value
	if (addCalled == 1)
	{
		SbVariant *vOutputWholeExtent = (SbVariant *)OutputWholeExtent.getValues(0);
		SoInput input;
		int nb_fields = OutputWholeExtent.getNum();

		int val0;
		int val1;
		int val2;
		int val3;
		int val4;
		int val5;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vOutputWholeExtent[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			input.read(val2);
			input.read(val3);
			input.read(val4);
			input.read(val5);
			mObject->SetOutputWholeExtent( 
				(int) val0,
				(int) val1,
				(int) val2,
				(int) val3,
				(int) val4,
				(int) val5
			);
		}
	}

	mObject->Update();
}
Esempio n. 10
0
SoNode *ReadString(char* string) {
   SoNode *node;
   SoInput in;
   in.setBuffer(string, strlen(string));
   node = SoDB::readAll(&in);
   node->ref();

   return node;
}
/// return the camera definition of the active view
static PyObject *
povViewCamera(PyObject *self, PyObject *args)
{
    // no arguments
    if (!PyArg_ParseTuple(args, ""))
        return NULL;
    PY_TRY {
        std::string out;
        const char* ppReturn=0;

        Gui::Application::Instance->sendMsgToActiveView("GetCamera",&ppReturn);

        SoNode* rootNode;
        SoInput in;
        in.setBuffer((void*)ppReturn,std::strlen(ppReturn));
        SoDB::read(&in,rootNode);

        if (!rootNode || !rootNode->getTypeId().isDerivedFrom(SoCamera::getClassTypeId()))
            throw Base::Exception("CmdRaytracingWriteCamera::activated(): Could not read "
                                  "camera information from ASCII stream....\n");

        // root-node returned from SoDB::readAll() has initial zero
        // ref-count, so reference it before we start using it to
        // avoid premature destruction.
        SoCamera * Cam = static_cast<SoCamera*>(rootNode);
        Cam->ref();

        SbRotation camrot = Cam->orientation.getValue();

        SbVec3f upvec(0, 1, 0); // init to default up vector
        camrot.multVec(upvec, upvec);

        SbVec3f lookat(0, 0, -1); // init to default view direction vector
        camrot.multVec(lookat, lookat);

        SbVec3f pos = Cam->position.getValue();
        float Dist = Cam->focalDistance.getValue();

        // making gp out of the Coin stuff
        gp_Vec gpPos(pos.getValue()[0],pos.getValue()[1],pos.getValue()[2]);
        gp_Vec gpDir(lookat.getValue()[0],lookat.getValue()[1],lookat.getValue()[2]);
        lookat *= Dist;
        lookat += pos;
        gp_Vec gpLookAt(lookat.getValue()[0],lookat.getValue()[1],lookat.getValue()[2]);
        gp_Vec gpUp(upvec.getValue()[0],upvec.getValue()[1],upvec.getValue()[2]);

        // getting image format
        ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Raytracing");
        int width = hGrp->GetInt("OutputWidth", 800);
        int height = hGrp->GetInt("OutputHeight", 600);

        // call the write method of PovTools....
        out = PovTools::getCamera(CamDef(gpPos,gpDir,gpLookAt,gpUp),width,height);

        return Py::new_reference_to(Py::String(out));
    } PY_CATCH;
}
void SoVtkImageEllipsoidSource::inputChanged(SoField * f)
{
	// Get the Radius value
	if ( f == &Radius )
		SO_VTK_SET_FIELD_VEC3F( mObject, Radius);

	// Get the OutputScalarType value
	if ( f == &OutputScalarType )
		SO_VTK_SET_FIELD_VALUE( mObject, OutputScalarType);

	// Get the OutValue value
	if ( f == &OutValue )
		SO_VTK_SET_FIELD_VALUE( mObject, OutValue);

	// Get the InValue value
	if ( f == &InValue )
		SO_VTK_SET_FIELD_VALUE( mObject, InValue);

	// Get the Center value
	if ( f == &Center )
		SO_VTK_SET_FIELD_VEC3F( mObject, Center);

	// Get the WholeExtent value
	if ( f == &WholeExtent )
	{
		SbVariant *vWholeExtent = (SbVariant *)WholeExtent.getValues(0);
		SoInput input;
		int nb_fields = WholeExtent.getNum();

		int val0;
		int val1;
		int val2;
		int val3;
		int val4;
		int val5;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vWholeExtent[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			input.read(val2);
			input.read(val3);
			input.read(val4);
			input.read(val5);
			mObject->SetWholeExtent( 
				(int) val0,
				(int) val1,
				(int) val2,
				(int) val3,
				(int) val4,
				(int) val5
			);
		}
	}

	mObject->Update();
}
void SoVtkGeometryFilter::inputChanged(SoField * f)
{
	// Get the CellClipping value
	if ( f == &CellClipping )
		SO_VTK_SET_FIELD_VALUE( mObject, CellClipping);

	// Get the Locator value
	if ( f == &Locator )
		SO_VTK_SET_FIELD_DATA( mObject, Locator, vtkPointLocator);

	// Get the PointClipping value
	if ( f == &PointClipping )
		SO_VTK_SET_FIELD_VALUE( mObject, PointClipping);

	// Get the ExtentClipping value
	if ( f == &ExtentClipping )
		SO_VTK_SET_FIELD_VALUE( mObject, ExtentClipping);

	// Get the Merging value
	if ( f == &Merging )
		SO_VTK_SET_FIELD_VALUE( mObject, Merging);

	// Get the Extent value
	if ( f == &Extent )
	{
		SbVariant *vExtent = (SbVariant *)Extent.getValues(0);
		SoInput input;
		int nb_fields = Extent.getNum();

		double val0;
		double val1;
		double val2;
		double val3;
		double val4;
		double val5;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vExtent[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			input.read(val2);
			input.read(val3);
			input.read(val4);
			input.read(val5);
			mObject->SetExtent( 
				(double) val0,
				(double) val1,
				(double) val2,
				(double) val3,
				(double) val4,
				(double) val5
			);
		}
	}

	mObject->Update();
}
osgDB::ReaderWriter::ReadResult
ReaderWriterIV::readNode(std::istream& fin,
                         const osgDB::ReaderWriter::Options* options) const
{
    // Notify
    OSG_NOTICE << "osgDB::ReaderWriterIV::readNode() "
              "Reading from stream." << std::endl;
    OSG_INFO << "osgDB::ReaderWriterIV::readNode() "
              "Inventor version: " << SoDB::getVersion() << std::endl;

    // Open the file
    SoInput input;

    // Assign istream to SoInput
    // note: It seems there is no straightforward way to do that.
    // SoInput accepts only FILE by setFilePointer or memory buffer
    // by setBuffer. The FILE is dangerous on Windows, since it forces
    // the plugin and Inventor DLL to use the same runtime library
    // (otherwise there are app crashes).
    // The memory buffer seems much better option here, even although
    // there will not be a real streaming. However, the model data
    // are usually much smaller than textures, so we should not worry
    // about it and think how to stream textures instead.

    // Get the data to the buffer
    size_t bufSize = 126*1024; // let's make it something below 128KB
    char *buf = (char*)malloc(bufSize);
    size_t dataSize = 0;
    while (!fin.eof() && fin.good()) {
        fin.read(buf+dataSize, bufSize-dataSize);
        dataSize += fin.gcount();
        if (bufSize == dataSize) {
           bufSize *= 2;
           char* new_buf = (char*)realloc(buf, bufSize);
           if (!new_buf)
           {
               free(buf);
               return osgDB::ReaderWriter::ReadResult::INSUFFICIENT_MEMORY_TO_LOAD;
           }
           buf = new_buf;
        }
    }
    input.setBuffer(buf, dataSize);
    OSG_INFO << "osgDB::ReaderWriterIV::readNode() "
              "Stream size: " << dataSize << std::endl;

    // Perform reading from SoInput
    osgDB::ReaderWriter::ReadResult r;
    std::string fileName("");
    r = readNodeFromSoInput(input, fileName, options);

    // clean up and return
    free(buf);
    return r;
}
void SoVtkEnSightGoldReader::reset()
{
	mObject->UnRegister(0);
	mObject->Delete();
	mObject = 0;
	mObject = vtkEnSightGoldReader::New();
	mObject->Register(0);
	mObject->SetGlobalWarningDisplay(0);
	// Get the input type(s)
	SoVtkAlgorithmOutput *inputPortPtr = InputConnection.getValue();
	
	if (inputPortPtr)
		mObject->SetInputConnection(inputPortPtr->getPointer());

	// Get the ByteOrder value
	
		SO_VTK_SET_FIELD_VALUE( mObject, ByteOrder);

	// Get the TimeValue value
	
		SO_VTK_SET_FIELD_VALUE( mObject, TimeValue);

	// Get the FilePath value
	
		SO_VTK_SET_FIELD_MFSTRING( mObject, FilePath);

	// Get the NumberOfInputConnections value
	if (addCalled == 1)
	{
		SbVariant *vNumberOfInputConnections = (SbVariant *)NumberOfInputConnections.getValues(0);
		SoInput input;
		int nb_fields = NumberOfInputConnections.getNum();

		int val0;
		int val1;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vNumberOfInputConnections[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			//mObject->SetNumberOfInputConnections( (int) val0, (int) val1 );
		}
	}

	// Get the CaseFileName value
	
		SO_VTK_SET_FIELD_MFSTRING( mObject, CaseFileName);

	// Get the ReadAllVariables value
	
		SO_VTK_SET_FIELD_VALUE( mObject, ReadAllVariables);

	mObject->Update();
}
Esempio n. 16
0
void SoVtkImageBlend::reset()
{
	mObject->UnRegister(0);
	mObject->Delete();
	mObject = 0;
	mObject = vtkImageBlend::New();
	mObject->Register(0);
	mObject->SetGlobalWarningDisplay(0);
	// Get the input type(s)
	SoVtkAlgorithmOutput *inputPortPtr = InputConnection.getValue();
	
	if (inputPortPtr)
		mObject->SetInputConnection(inputPortPtr->getPointer());

	// Get the Stencil value
	
		SO_VTK_SET_FIELD_DATA( mObject, Stencil, vtkImageStencilData);

	// Get the CompoundThreshold value
	
		SO_VTK_SET_FIELD_VALUE( mObject, CompoundThreshold);

	// Get the NumberOfThreads value
	
		SO_VTK_SET_FIELD_VALUE( mObject, NumberOfThreads);

	// Get the Opacity value
	if (addCalled == 1)
	{
		SbVariant *vOpacity = (SbVariant *)Opacity.getValues(0);
		SoInput input;
		int nb_fields = Opacity.getNum();

		int val0;
		double val1;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vOpacity[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			mObject->SetOpacity( 
				(int) val0,
				(double) val1
			);
		}
	}

	// Get the BlendMode value
	
		SO_VTK_SET_FIELD_VALUE( mObject, BlendMode);

	mObject->Update();
}
void SoVtkImageAccumulate::inputChanged(SoField * f)
{
	// Get the ReverseStencil value
	if ( f == &ReverseStencil )
		SO_VTK_SET_FIELD_VALUE( mObject, ReverseStencil);

	// Get the ComponentExtent value
	if ( f == &ComponentExtent )
	{
		SbVariant *vComponentExtent = (SbVariant *)ComponentExtent.getValues(0);
		SoInput input;
		int nb_fields = ComponentExtent.getNum();

		int val0;
		int val1;
		int val2;
		int val3;
		int val4;
		int val5;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vComponentExtent[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			input.read(val2);
			input.read(val3);
			input.read(val4);
			input.read(val5);
			mObject->SetComponentExtent( 
				(int) val0,
				(int) val1,
				(int) val2,
				(int) val3,
				(int) val4,
				(int) val5
			);
		}
	}

	// Get the Stencil value
	if ( f == &Stencil )
		SO_VTK_SET_FIELD_DATA( mObject, Stencil, vtkImageStencilData);

	// Get the ComponentSpacing value
	if ( f == &ComponentSpacing )
		SO_VTK_SET_FIELD_VEC3F( mObject, ComponentSpacing);

	// Get the ComponentOrigin value
	if ( f == &ComponentOrigin )
		SO_VTK_SET_FIELD_VEC3F( mObject, ComponentOrigin);

	mObject->Update();
}
Esempio n. 18
0
void SoVtkExtractGrid::inputChanged(SoField * f)
{
	// Get the VOI value
	if ( f == &VOI )
	{
		if ( VOI.getNum() >= 6)
		{
			SO_VTK_SET_FIELD_MFINT32( mObject, VOI);
		}
		else
		{
			SoDebugError::post( __FILE__, "This field must have 6 values." );
		}
	}

	// Get the SampleRate value
	if ( f == &SampleRate )
		SO_VTK_SET_FIELD_VEC3F( mObject, SampleRate);

	// Get the InputArrayToProcess value
	if ( f == &InputArrayToProcess )
	{
		SbVariant vInputArrayToProcess = (SbVariant)InputArrayToProcess.getValue();
		SoInput input;
		int val0;
		int val1;
		int val2;
		int val3;
		SbString val4;
	
		input.setBuffer((void *)vInputArrayToProcess.getField().getString(),256);
		input.read(val0);
		input.read(val1);
		input.read(val2);
		input.read(val3);
		input.read(val4);
		mObject->SetInputArrayToProcess( 
			(int) val0,
			(int) val1,
			(int) val2,
			(int) val3,
			val4.getString()
		);
	}
	// Get the IncludeBoundary value
	if ( f == &IncludeBoundary )
		SO_VTK_SET_FIELD_VALUE( mObject, IncludeBoundary);

	//mObject->Update();
	
}
void ViewProviderInventorObject::updateData(const App::Property* prop)
{
    App::InventorObject* ivObj = static_cast<App::InventorObject*>(pcObject);
    if (prop == &ivObj->Buffer) {
        // read from buffer
        SoInput in;
        std::string buffer = ivObj->Buffer.getValue();
        pcBuffer->removeAllChildren();
        if (buffer.empty()) return;
        in.setBuffer((void *)buffer.c_str(), buffer.size());
        SoSeparator * node = SoDB::readAll(&in);
        if (node) {
            const char* doc = this->pcObject->getDocument()->getName();
            const char* obj = this->pcObject->getNameInDocument();
            adjustSelectionNodes(node, doc, obj);
            pcBuffer->addChild(node);
        }
    }
    if (prop == &ivObj->FileName) {
        // read also from file
        const char* filename = ivObj->FileName.getValue();
        QString fn = QString::fromUtf8(filename);
        QFile file(fn);
        SoInput in;
        pcFile->removeAllChildren();
        if (!fn.isEmpty() && file.open(QFile::ReadOnly)) {
            QByteArray buffer = file.readAll();
            in.setBuffer((void *)buffer.constData(), buffer.length());
            SoSeparator * node = SoDB::readAll(&in);
            if (node) {
                const char* doc = this->pcObject->getDocument()->getName();
                const char* obj = this->pcObject->getNameInDocument();
                adjustSelectionNodes(node, doc, obj);
                pcFile->addChild(node);
            }
        }
    }
}
Esempio n. 20
0
void SoVtkContourGrid::inputChanged(SoField * f)
{
	// Get the NumberOfContours value
	if ( f == &NumberOfContours )
		SO_VTK_SET_FIELD_VALUE( mObject, NumberOfContours);

	// Get the Value value
	if ( f == &Value )
	{
		SbVariant *vValue = (SbVariant *)Value.getValues(0);
		SoInput input;
		int nb_fields = Value.getNum();

		int val0;
		double val1;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vValue[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			mObject->SetValue( 
				(int) val0,
				(double) val1
			);
		}
	}

	// Get the ComputeScalars value
	if ( f == &ComputeScalars )
		SO_VTK_SET_FIELD_VALUE( mObject, ComputeScalars);

	// Get the UseScalarTree value
	if ( f == &UseScalarTree )
		SO_VTK_SET_FIELD_VALUE( mObject, UseScalarTree);

	// Get the ComputeGradients value
	if ( f == &ComputeGradients )
		SO_VTK_SET_FIELD_VALUE( mObject, ComputeGradients);

	// Get the Locator value
	if ( f == &Locator )
		SO_VTK_SET_FIELD_DATA( mObject, Locator, vtkPointLocator);

	// Get the ComputeNormals value
	if ( f == &ComputeNormals )
		SO_VTK_SET_FIELD_VALUE( mObject, ComputeNormals);

	mObject->Update();
}
void SoVtkImageDataGeometryFilter::inputChanged(SoField * f)
{
	// Get the OutputTriangles value
	if ( f == &OutputTriangles )
		SO_VTK_SET_FIELD_VALUE( mObject, OutputTriangles);

	// Get the Extent value
	if ( f == &Extent )
	{
		SbVariant *vExtent = (SbVariant *)Extent.getValues(0);
		SoInput input;
		int nb_fields = Extent.getNum();

		int val0;
		int val1;
		int val2;
		int val3;
		int val4;
		int val5;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vExtent[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			input.read(val2);
			input.read(val3);
			input.read(val4);
			input.read(val5);
			mObject->SetExtent( 
				(int) val0,
				(int) val1,
				(int) val2,
				(int) val3,
				(int) val4,
				(int) val5
			);
		}
	}

	// Get the ThresholdCells value
	if ( f == &ThresholdCells )
		SO_VTK_SET_FIELD_VALUE( mObject, ThresholdCells);

	// Get the ThresholdValue value
	if ( f == &ThresholdValue )
		SO_VTK_SET_FIELD_VALUE( mObject, ThresholdValue);

	mObject->Update();
}
void SoVtkImageGaussianSource::inputChanged(SoField * f)
{
	// Get the Maximum value
	if ( f == &Maximum )
		SO_VTK_SET_FIELD_VALUE( mObject, Maximum);

	// Get the StandardDeviation value
	if ( f == &StandardDeviation )
		SO_VTK_SET_FIELD_VALUE( mObject, StandardDeviation);

	// Get the Center value
	if ( f == &Center )
		SO_VTK_SET_FIELD_VEC3F( mObject, Center);

	// Get the WholeExtent value
	if ( f == &WholeExtent )
	{
		SbVariant *vWholeExtent = (SbVariant *)WholeExtent.getValues(0);
		SoInput input;
		int nb_fields = WholeExtent.getNum();

		int val0;
		int val1;
		int val2;
		int val3;
		int val4;
		int val5;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vWholeExtent[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			input.read(val2);
			input.read(val3);
			input.read(val4);
			input.read(val5);
			mObject->SetWholeExtent( 
				(int) val0,
				(int) val1,
				(int) val2,
				(int) val3,
				(int) val4,
				(int) val5
			);
		}
	}

	mObject->Update();
}
Esempio n. 23
0
//////////////////////////////////////////////////////////////////////////////
//
//  Description:
//    Convert the passed byte stream to a path list.
//    The caller should delete the returned path list when done with it.
//
//  Use: static, public
//
SoPathList *
SoByteStream::unconvert(void *data, uint32_t numBytes)
//
//////////////////////////////////////////////////////////////////////////////
{
    if (data == NULL) {
	SoDebugError::post("SoByteStream::unconvert", "data is NULL");
	return NULL;
    }
    if (numBytes == 0) {
	SoDebugError::post("SoByteStream::unconvert", "numBytes is 0");
	return NULL;
    }

    SoInput in;
    SoPathList *pathList = new SoPathList;
    SoPath  *path = NULL;

    in.setBuffer((void *) data, (size_t) numBytes);
    
    // Try to read paths
    while ((SoDB::read(&in, path) != FALSE) && (path != NULL))
    	pathList->append(path);

    // If that failed, try reading the scene as a node
    if (pathList->getLength() == 0) {
	in.setBuffer((void *) data, (size_t) numBytes); // reset
	SoSeparator *sep = SoDB::readAll(&in);		// read again
	if (sep != NULL) {
	    path = new SoPath(sep);
	    pathList->append(path);
	}
    }

    return pathList;
}
Esempio n. 24
0
void SoVtkHull::reset()
{
	mObject->UnRegister(0);
	mObject->Delete();
	mObject = 0;
	mObject = vtkHull::New();
	mObject->Register(0);
	mObject->SetGlobalWarningDisplay(0);
	// Get the input type(s)
	SoVtkAlgorithmOutput *inputPortPtr = InputConnection.getValue();
	
	if (inputPortPtr)
		mObject->SetInputConnection(inputPortPtr->getPointer());

	// Get the Planes value
	
		SO_VTK_SET_FIELD_DATA( mObject, Planes, vtkPlanes);

	// Get the Plane value
	if (addCalled == 1)
	{
		SbVariant *vPlane = (SbVariant *)Plane.getValues(0);
		SoInput input;
		int nb_fields = Plane.getNum();

		double val0;
		double val1;
		double val2;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vPlane[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			input.read(val2);
			mObject->AddPlane( 
				(double) val0,
				(double) val1,
				(double) val2
			);
		}
	}

	// Get the RecursiveSpherePlanes value
	
		SO_VTK_ADD_FIELD_VALUE( mObject, RecursiveSpherePlanes);

	mObject->Update();
}
void SoVtkEnSightGoldBinaryReader::inputChanged(SoField * f)
{
	// Get the ByteOrder value
	if ( f == &ByteOrder )
		SO_VTK_SET_FIELD_VALUE( mObject, ByteOrder);

	// Get the TimeValue value
	if ( f == &TimeValue )
		SO_VTK_SET_FIELD_VALUE( mObject, TimeValue);

	// Get the FilePath value
	if ( f == &FilePath )
		SO_VTK_SET_FIELD_MFSTRING( mObject, FilePath);

	// Get the NumberOfInputConnections value
	if ( f == &NumberOfInputConnections )
	{
		SbVariant *vNumberOfInputConnections = (SbVariant *)
		  NumberOfInputConnections.getValues(0);

		SoInput input;
		int nb_fields = NumberOfInputConnections.getNum();

		int val0;
		int val1;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vNumberOfInputConnections[i].getField().
			  getString(),256);

			input.read(val0);
			input.read(val1);

			//mObject->SetNumberOfInputConnections( (int) val0, (int) val1 );
		}
	}

	// Get the CaseFileName value
	if ( f == &CaseFileName )
		SO_VTK_SET_FIELD_MFSTRING( mObject, CaseFileName);

	// Get the ReadAllVariables value
	if ( f == &ReadAllVariables )
		SO_VTK_SET_FIELD_VALUE( mObject, ReadAllVariables);

	mObject->Update();
}
Esempio n. 26
0
void SoVtkImageWrapPad::inputChanged(SoField * f)
{
	// Get the OutputNumberOfScalarComponents value
	if ( f == &OutputNumberOfScalarComponents )
		SO_VTK_SET_FIELD_VALUE( mObject, OutputNumberOfScalarComponents);

	// Get the NumberOfThreads value
	if ( f == &NumberOfThreads )
		SO_VTK_SET_FIELD_VALUE( mObject, NumberOfThreads);

	// Get the OutputWholeExtent value
	if ( f == &OutputWholeExtent )
	{
		SbVariant *vOutputWholeExtent = (SbVariant *)OutputWholeExtent.getValues(0);
		SoInput input;
		int nb_fields = OutputWholeExtent.getNum();

		int val0;
		int val1;
		int val2;
		int val3;
		int val4;
		int val5;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vOutputWholeExtent[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			input.read(val2);
			input.read(val3);
			input.read(val4);
			input.read(val5);
			mObject->SetOutputWholeExtent( 
				(int) val0,
				(int) val1,
				(int) val2,
				(int) val3,
				(int) val4,
				(int) val5
			);
		}
	}

	mObject->Update();
}
void SoVtkImageVariance3D::reset()
{
	mObject->UnRegister(0);
	mObject->Delete();
	mObject = 0;
	mObject = vtkImageVariance3D::New();
	mObject->Register(0);
	mObject->SetGlobalWarningDisplay(0);
	// Get the input type(s)
	SoVtkAlgorithmOutput *inputPortPtr = InputConnection.getValue();
	
	if (inputPortPtr)
		mObject->SetInputConnection(inputPortPtr->getPointer());

	// Get the KernelSize value
	if (addCalled == 1)
	{
		SbVariant *vKernelSize = (SbVariant *)KernelSize.getValues(0);
		SoInput input;
		int nb_fields = KernelSize.getNum();

		int val0;
		int val1;
		int val2;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vKernelSize[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			input.read(val2);
			mObject->SetKernelSize( 
				(int) val0,
				(int) val1,
				(int) val2
			);
		}
	}

	// Get the NumberOfThreads value
	
		SO_VTK_SET_FIELD_VALUE( mObject, NumberOfThreads);

	mObject->Update();
}
Esempio n. 28
0
void
SoXtMaterialList::selectionCallback(// private
  int materialid)
{
  materialid--; // get index
  SoXtMaterialDirectory * data = common->getMaterialDirectory();

  assert(materialid >= 0 &&
          materialid < data->groups[data->current]->numMaterials);
  const char * materialdata =
    data->groups[data->current]->materials[materialid]->data;

  SoInput reader;
  if (data->flags & SOXT_BUILTIN_MATERIALS) {
    reader.setBuffer((void *) materialdata, strlen(materialdata));
  } else {
    if (! reader.openFile(materialdata, FALSE)) {
      SoDebugError::postWarning("SoXtMaterialList::selectionCallback",
        "could not open file: \"%s\"", materialdata);
      return;
    }
  }

  SoNode * material = NULL;
  if (! SoDB::read(&reader, material)) {
    SoDebugError::postWarning("SoXtMaterialList::selectionCallback",
      "failed to read material");
    return;
  }
  if (! material) {
    SoDebugError::postWarning("SoXtMaterialList::selectionCallback",
      "read returned no data");
    return;
  }
  material->ref();
  if (! material->isOfType(SoMaterial::getClassTypeId())) {
    SoDebugError::postWarning("SoXtMaterialList::selectionCallback",
      "not a material node!");
    material->unref();
    return;
  }
  common->invokeCallbacks((SoMaterial *) material);
  material->unref();
} // selectionCallback()
void SoVtkGenericProbeFilter::reset()
{
	mObject->UnRegister(0);
	mObject->Delete();
	mObject = 0;
	mObject = vtkGenericProbeFilter::New();
	mObject->Register(0);
	mObject->SetGlobalWarningDisplay(0);
	// Get the input type(s)
	SoVtkObject *inputPtr = Input.getValue();
	
	if (inputPtr && inputPtr->getPointer()->IsA("vtkDataSet"))
		mObject->SetInput(vtkDataSet::SafeDownCast(inputPtr->getPointer()));

	SoVtkAlgorithmOutput *inputPortPtr = InputConnection.getValue();
	if (inputPortPtr)
		mObject->SetInputConnection(inputPortPtr->getPointer());

	// Get the Source value
	
		SO_VTK_SET_FIELD_DATA( mObject, Source, vtkGenericDataSet);

	// Get the NumberOfInputConnections value
	if (addCalled == 1)
	{
		SbVariant *vNumberOfInputConnections = (SbVariant *)NumberOfInputConnections.getValues(0);
		SoInput input;
		int nb_fields = NumberOfInputConnections.getNum();

		int val0;
		int val1;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vNumberOfInputConnections[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			//mObject->SetNumberOfInputConnections( (int) val0, (int) val1 );
		}
	}

	mObject->Update();
}
Esempio n. 30
0
void SoVtkImageBlend::inputChanged(SoField * f)
{
	// Get the Stencil value
	if ( f == &Stencil )
		SO_VTK_SET_FIELD_DATA( mObject, Stencil, vtkImageStencilData);

	// Get the CompoundThreshold value
	if ( f == &CompoundThreshold )
		SO_VTK_SET_FIELD_VALUE( mObject, CompoundThreshold);

	// Get the NumberOfThreads value
	if ( f == &NumberOfThreads )
		SO_VTK_SET_FIELD_VALUE( mObject, NumberOfThreads);

	// Get the Opacity value
	if ( f == &Opacity )
	{
		SbVariant *vOpacity = (SbVariant *)Opacity.getValues(0);
		SoInput input;
		int nb_fields = Opacity.getNum();

		int val0;
		double val1;
		for (int i=0; i < nb_fields; i++)
		{
			input.setBuffer((void *)vOpacity[i].getField().getString(),256);
			input.read(val0);
			input.read(val1);
			mObject->SetOpacity( 
				(int) val0,
				(double) val1
			);
		}
	}

	// Get the BlendMode value
	if ( f == &BlendMode )
		SO_VTK_SET_FIELD_VALUE( mObject, BlendMode);

	mObject->Update();
}